Need help changing AndroidManifest.xml in an APK file

1.7k views Asked by At

I'm trying to make a minor change to AndroidManifest.xml using the APK Multi Tool (apktool). I am able to disassemble and make the change, but when I try to reassemble into a new APK, I get an error:

error: Error retrieving parent for item: No resource found that matches the given name 'Preference'.

I believe that the line in the styles.xml is:

<style name="Preference.SwitchPreference">
    <item name="android:layout">@layout/preference</item>
    <item name="android:widgetLayout">@layout/preference_widget_switch</item>
</style>

Here is the full error log:

-------------------------------------------------------------------------- 
|Tue 12/10/2013 -- 23:18:05.27| 
-------------------------------------------------------------------------- 
java version "1.7.0_13"
Java(TM) SE Runtime Environment (build 1.7.0_13-b20)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
I: Baksmaling...
I: Loading resource table...
I: Loaded.
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: C:\Users\Sean\apktool\framework\1.apk
I: Loaded.
I: Renamed manifest package found! Fixing...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Done.
I: Copying assets and libs...
I: Checking whether sources has changed...
I: Smaling...
I: Checking whether resources has changed...
I: Building resources...
C:\Users\Sean\Downloads\APK-Multi-Tool\other\..\projects\Test.apk\res\values\styles.xml:105: error: Error retrieving parent for item: No resource found that matches the given name 'Preference'.
Exception in thread "main" brut.androlib.AndrolibException: brut.androlib.AndrolibException: brut.common.BrutException: could not exec command: [aapt, p, --min-sdk-version, 13, --target-sdk-version, 17, -F, C:\Users\Sean\AppData\Local\Temp\APKTOOL1118131662295957481.tmp, -0, arsc, -I, C:\Users\Sean\apktool\framework\1.apk, -S, C:\Users\Sean\Downloads\APK-Multi-Tool\other\..\projects\Test.apk\res, -M, C:\Users\Sean\Downloads\APK-Multi-Tool\other\..\projects\Test.apk\AndroidManifest.xml]
    at brut.androlib.Androlib.buildResourcesFull(Androlib.java:358)
    at brut.androlib.Androlib.buildResources(Androlib.java:283)
    at brut.androlib.Androlib.build(Androlib.java:206)
    at brut.androlib.Androlib.build(Androlib.java:176)
    at brut.apktool.Main.cmdBuild(Main.java:228)
    at brut.apktool.Main.main(Main.java:79)
Caused by: brut.androlib.AndrolibException: brut.common.BrutException: could not exec command: [aapt, p, --min-sdk-version, 13, --target-sdk-version, 17, -F, C:\Users\Sean\AppData\Local\Temp\APKTOOL1118131662295957481.tmp, -0, arsc, -I, C:\Users\Sean\apktool\framework\1.apk, -S, C:\Users\Sean\Downloads\APK-Multi-Tool\other\..\projects\Test.apk\res, -M, C:\Users\Sean\Downloads\APK-Multi-Tool\other\..\projects\Test.apk\AndroidManifest.xml]
    at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:357)
    at brut.androlib.Androlib.buildResourcesFull(Androlib.java:336)
    ... 5 more
Caused by: brut.common.BrutException: could not exec command: [aapt, p, --min-sdk-version, 13, --target-sdk-version, 17, -F, C:\Users\Sean\AppData\Local\Temp\APKTOOL1118131662295957481.tmp, -0, arsc, -I, C:\Users\Sean\apktool\framework\1.apk, -S, C:\Users\Sean\Downloads\APK-Multi-Tool\other\..\projects\Test.apk\res, -M, C:\Users\Sean\Downloads\APK-Multi-Tool\other\..\projects\Test.apk\AndroidManifest.xml]
    at brut.util.OS.exec(OS.java:89)
    at brut.androlib.res.AndrolibResources.aaptPackage(AndrolibResources.java:355)
    ... 6 more

Any idea on how to resolve this? Can I somehow build the APK without decompiling and compiling the code, since I'm not making a code change? Thanks.

1

There are 1 answers

1
Mikalai Daronin On BEST ANSWER

Little trick: add a new style to styles.xml:

<style name="Preference" />