Apktool icon indicating copy to clipboard operation
Apktool copied to clipboard

[Compile error framework-res.apk] Resource entry Theme.Holo already has bag item textEditSuggestionItemLayout.

Open haiqalshii opened this issue 4 years ago • 8 comments

Information

  1. Apktool Version (apktool -version) - 2.5.0
  2. Operating System (Mac, Linux, Windows) - Windows 10 Pro
  3. APK From? (Playstore, ROM, Other) - AOSP Android 9.0 for ASUS_X00LD

Stacktrace/Logcat

Compiling APK file... (Press ESC to cancel)

/c "java -Xmx1024m -jar "C:\Program Files (x86)\APK Easy Tool\Apktool\apktool_2.5.0.jar" b -f -o "C:\Users\Administrator\Documents\APK Easy Tool\2-Recompiled APKs\framework-res.apk" "C:\Users\Administrator\Documents\APK Easy Tool\1-Decompiled APKs\framework-res" "

I: Using Apktool 2.5.0 W: Could not find sources I: Building resources... W: C:\Users\Administrator\Documents\APK Easy Tool\1-Decompiled APKs\framework-res\res\values\styles.xml:1184: error: Resource entry Theme.Holo already has bag item textEditSuggestionItemLayout. W: C:\Users\Administrator\Documents\APK Easy Tool\1-Decompiled APKs\framework-res\res\values\styles.xml:1183: Originally defined here. W: W: C:\Users\Administrator\Documents\APK Easy Tool\1-Decompiled APKs\framework-res\res\values\styles.xml:1260: error: Resource entry Theme.Holo already has bag item preferenceFrameLayoutStyle. W: C:\Users\Administrator\Documents\APK Easy Tool\1-Decompiled APKs\framework-res\res\values\styles.xml:1259: Originally defined here. W: W: C:\Users\Administrator\Documents\APK Easy Tool\1-Decompiled APKs\framework-res\res\values\styles.xml:1269: error: Resource entry Theme.Holo already has bag item textEditSuggestionContainerLayout. W: C:\Users\Administrator\Documents\APK Easy Tool\1-Decompiled APKs\framework-res\res\values\styles.xml:1268: Originally defined here. W: W: C:\Users\Administrator\Documents\APK Easy Tool\1-Decompiled APKs\framework-res\res\values\styles.xml:1271: error: Resource entry Theme.Holo already has bag item textEditSuggestionHighlightStyle. W: C:\Users\Administrator\Documents\APK Easy Tool\1-Decompiled APKs\framework-res\res\values\styles.xml:1270: Originally defined here. W: brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [C:\Users\ADMINI~1\AppData\Local\Temp\brut_util_Jar_58334102865100678537102944826996642900.tmp, p, --forced-package-id, 1, --min-sdk-version, 28, --target-sdk-version, 28, --version-code, 28, --version-name, 9, --no-version-vectors, -F, C:\Users\ADMINI~1\AppData\Local\Temp\APKTOOL5357856494746311717.tmp, -x, -e, C:\Users\ADMINI~1\AppData\Local\Temp\APKTOOL9110140203189688992.tmp, -0, arsc, -S, C:\Users\Administrator\Documents\APK Easy Tool\1-Decompiled APKs\framework-res\res, -M, C:\Users\Administrator\Documents\APK Easy Tool\1-Decompiled APKs\framework-res\AndroidManifest.xml] Compile successful.

Please read the FAQ and troubleshooting https://forum.xda-developers.com/t/tool-windows-apk-easy-tool-v1-57-12-june-2020.3333960/#post-65775601

Include stacktrace here

Steps to Reproduce

I used Easy APK Tool, basically what I am trying to do is changing the minimum screen brightness in the framework-res.apk. The values are in framework-res\res\values\integers.xml. Decompiling has no problem, but when I tried to recompile the APK it shows up this error. I've tried to decompile and recompile the apk without doing any changes at all, but this error shows up. I've also tried to use previous version of APK tool, and by using the CMD method but it's still showing up this error. I believe that this is a bug from the original file itself because I did not modify the file 'styles.xml'. From the issue #2290 posted by @Magendanz, it is fixed by deleting the doubled entries in the file, but I have no idea which one is it. How do I fix it?

APK

If this APK can be freely shared, please upload/attach a link to it. https://mega.nz/file/ZoMmGBza#q4uFbotDT_N2V66fXfVthqN6I9Ha-k0RYd6xvRieBAU

Questions to ask before submission

  1. Have you tried apktool d, apktool b without changing anything? No,
  2. If you are trying to install a modified apk, did you resign it? No.
  3. Are you using the latest apktool version? Yes.

haiqalshii avatar Dec 22 '20 14:12 haiqalshii

@icypeach replace the original aapt's in apktool with these to work with framework-res.apk: [redacted]

# java -jar apktool_2.5.0.jar b framework-res --use-aapt2
I: Using Apktool 2.5.0
W: Could not find sources
I: Checking whether resources has changed...
I: Building resources...
I: Building apk file...
I: Copying unknown files/dir...
I: Built apk...

pashamcr avatar Dec 22 '20 19:12 pashamcr

@icypeach replace the original aapt's in apktool with these to work with framework-res.apk: [redacted]

# java -jar apktool_2.5.0.jar b framework-res --use-aapt2
I: Using Apktool 2.5.0
W: Could not find sources
I: Checking whether resources has changed...
I: Building resources...
I: Building apk file...
I: Copying unknown files/dir...
I: Built apk...

I've removed the link. I don't trust sharing prebuilt binaries. Please put a pull request forward to change aapt binaries if you want to put forward a change.

iBotPeaches avatar Dec 22 '20 19:12 iBotPeaches

@iBotPeaches I cannot check your aapt's, they do not work on my old computer, I informed you about this earlier; excluding ssse3 & sse4.1 optimization for zlib would solve the problem, but slow down performance on newer processors; external/zlib is not included in platform_frameworks_base, but is included in aapt's, so I compiled aapt's for myself separately, with the zlib patch; showed the build command and the tool it used, i.e. compiled by me aapt, so that @icypeach can check that the command with the --use-aapt2 flag really works (whether it works on yours - I don't know): I apologize for the thoughtless advice to replace aapt @icypeach

pashamcr avatar Dec 22 '20 21:12 pashamcr

@pashamcr That's very kind of you trying to help, but nevermind I've figured myself out on how to fix it. I believe that everyone on stock AOSP 9.0 will face this problem when trying to compile the APK, as this bug is from the original file from Google itself. So here's the fix:

  1. Open the file styles.xml in \framework-res\res\values using any text editor (Windows Notepad will do)

  2. Use the find option to find these entries: "textEditSuggestionItemLayout">@layout/text_edit_suggestion_item "preferenceFrameLayoutStyle">@style/Widget.Holo.PreferenceFrameLayout "textEditSuggestionContainerLayout">@layout/text_edit_suggestion_container "textEditSuggestionHighlightStyle">@style/TextAppearance.Holo.SuggestionHighlight

  3. Each of these entries will have a duplicate below them, now just delete them

  4. Save the file and try to compile the APK

haiqalshii avatar Dec 23 '20 00:12 haiqalshii

But another problem comes after I replaced the original framework-res.apk, which is my phone stucked on black screen after reboot (It passes the bootanimation). Basically now it's on bootloop(and I don't really mind cause I've made a backup). I guess the systemui failed to launch. I've done readings on XDA and Reddit before posting this comment, and people have been saying that the modified APK should be signed. I've signed the APK and done the zipalign successfully. Where did I went wrong? And is it appropriate to ask this here, or should I close this issue and create another?

haiqalshii avatar Dec 23 '20 00:12 haiqalshii

I cannot check your aapt's, they do not work on my old computer, I informed you about this earlier;

Could you put forward a patch? Its hard for me to track things that aren't a PR waiting. Just too much output.

iBotPeaches avatar Dec 24 '20 12:12 iBotPeaches

But another problem comes after I replaced the original framework-res.apk, which is my phone stucked on black screen after reboot (It passes the bootanimation). Basically now it's on bootloop(and I don't really mind cause I've made a backup). I guess the systemui failed to launch. I've done readings on XDA and Reddit before posting this comment, and people have been saying that the modified APK should be signed. I've signed the APK and done the zipalign successfully. Where did I went wrong? And is it appropriate to ask this here, or should I close this issue and create another?

Generally the logcat will point at what went wrong, but it won't be easy to understand exactly.


I'm going to dig into why this is duping, since this is part of the resources.arsc. It won't be as easy to dump out, but seeing this:

        <item name="switchPreferenceStyle">@style/Preference.Holo.SwitchPreference</item>
        <item name="textEditSuggestionItemLayout">@layout/text_edit_suggestion_item</item>
        <item name="textEditSuggestionItemLayout">@layout/text_edit_suggestion_item</item>
        <item name="actionModeSelectAllDrawable">@drawable/ic_menu_selectall_holo_dark</item>

A clear duplicate is just strange.

iBotPeaches avatar Jan 03 '21 19:01 iBotPeaches

i had the same issue is there no othe way to recompile it?

HaythamTantoush avatar Sep 10 '21 22:09 HaythamTantoush

Resolved with: https://github.com/iBotPeaches/Apktool/commit/86340503acd4f81d8b3decc1f60f35b30faa8d72

iBotPeaches avatar Jul 10 '23 01:07 iBotPeaches

Resolved with: 8634050

not solved i have still the same error

chiron853 avatar Jul 15 '23 18:07 chiron853