Apktool icon indicating copy to clipboard operation
Apktool copied to clipboard

Resource entry already has bag item (double entity)

Open datdevs opened this issue 7 years ago • 15 comments

Information

  1. Apktool Version (apktool -version) - 2.3.4
  2. Operating System (Mac, Linux, Windows) - Windows
  3. APK From? (Playstore, ROM, Other) - ROM

Stacktrace/Logcat

W: E:\ANDROID-G\AndroidDEV\AdvancedApkTool\3-Out\framework-res.apk\res\values\styles.xml:2452: error: Resource entry Theme.DeviceDefault already has bag item dropdownListPreferredItemHeight. W: E:\ANDROID-G\AndroidDEV\AdvancedApkTool\3-Out\framework-res.apk\res\values\styles.xml:2451: Originally defined here.


### Steps to Reproduce
1. apktool if framework-res.apk
2. apktool d framework-res.apk
3. apktool b framework-res

### Questions to ask before submission
1. Have you tried `apktool d`, `apktool b` without changing anything?
2. If you are trying to install a modified apk, did you resign it?
3. Are you using the latest apktool version?

datdevs avatar Oct 28 '18 18:10 datdevs

To be honest @datdevs...

The Advanced Apktool software hasn't been updated by @BDFreak since 10 Feb 2016 as reflected on the following link.

https://forum.xda-developers.com/showthread.php?t=2639400

I do believe that @BDFreak is a very good developer but, I just wish that he would update the Advanced Apktool software since, at the time, it was an extremely valuable tool out there.

I'm just providing my thoughts and pointing something out that you may not be aware of.

Good Luck! :-)

~Ibuprophen

Ibuprophen avatar Oct 28 '18 18:10 Ibuprophen

any body know about this problem

gsmmazhar avatar Oct 29 '18 11:10 gsmmazhar

i also faced this problem

gsmmazhar avatar Oct 29 '18 11:10 gsmmazhar

just delete doubles..

ingbrzy avatar Oct 29 '18 11:10 ingbrzy

if we delete phone rebooting and stuck at bootloop

gsmmazhar avatar Oct 29 '18 11:10 gsmmazhar

you test and try it

gsmmazhar avatar Oct 29 '18 11:10 gsmmazhar

Do you have an apk for this? I'm curious if the duplicated resources exist in the original or if apktool decoded them improperly.

iBotPeaches avatar Nov 01 '18 20:11 iBotPeaches

yes i have an apk i can upload you try on this unpack and repack

gsmmazhar avatar Nov 01 '18 21:11 gsmmazhar

C:\Users\Piya Jee\Desktop\apktool2 work on oreo>apktool b framework-res I: Using Apktool 2.3.4_0503 W: Could not find sources I: Checking whether resources has changed... I: Building resources... W: C:\Users\Piya Jee\Desktop\apktool2 work on oreo\framework-res\res\values\styles.xml:2452: error: Resource entry Theme.DeviceDefault already has bag item dropdownListPreferredItemHeight. W: C:\Users\Piya Jee\Desktop\apktool2 work on oreo\framework-res\res\values\styles.xml:2451: Originally defined here. W: brut.androlib.AndrolibException: brut.common.BrutException: could not exec (exit code = 1): [C:\Users\PIYAJE~1\AppData\Local\Temp\brut_util_Jar_96045326345974598.tmp, p, --forced-package-id, 1, --min-sdk-version, 26, --target-sdk-version, 26, --version-code, 26, --version-name, 8.0.0, --no-version-vectors, -F, C:\Users\PIYAJE~1\AppData\Local\Temp\APKTOOL2390478510879530650.tmp, -x, -0, arsc, -0, qmg, -0, arsc, -S, C:\Users\Piya Jee\Desktop\apktool2 work on oreo\framework-res\res, -M, C:\Users\Piya Jee\Desktop\apktool2 work on oreo\framework-res\AndroidManifest.xml]

gsmmazhar avatar Nov 01 '18 21:11 gsmmazhar

https://drive.google.com/open?id=1Z3jgUkG3pNlnYi68XxqtQ-aKpWng8NqH

gsmmazhar avatar Nov 01 '18 21:11 gsmmazhar

this is stock framework-res.apk try and please tell me solution for this

gsmmazhar avatar Nov 01 '18 21:11 gsmmazhar

Closing as duplicate - https://github.com/iBotPeaches/Apktool/issues/315

iBotPeaches avatar Nov 29 '20 14:11 iBotPeaches

@iBotPeaches Are you sure this is a duplicate of #315? :thinking:

That issue is talking about extraneous double quotes inside of otherwise successfully re-encoded APKs, whereas this one is talking about an error causing the re-encoding to fail for reasons that have nothing to do with quotes or even strings for that matter.

The base APK inside of the TikTok XAPK for example causes the following error while re-encoding:

W: <decode_dir>/res/values-v21/styles.xml:265: error: Resource entry iz already has bag item android:windowContentTransitions.
W: <decode_dir>/res/values-v21/styles.xml:264: Originally defined here.

The "resource entry" mentioned in the error message looks like this:

<style name="iz" parent="@style/fc">
    <item name="android:windowBackground">@drawable/o5</item>
    <item name="android:windowContentTransitions">true</item>
    <item name="android:windowContentTransitions">true</item> <!-- Duplicate item -->
    <item name="android:windowSharedElementEnterTransition">@transition/a</item>
    <item name="android:windowSharedElementExitTransition">@transition/a</item>
    <item name="android:windowSharedElementReturnTransition">@transition/a</item>
    <item name="android:windowSharedElementReenterTransition">@transition/a</item>
</style>

I suggest reopening this issue and renaming it to Resource entry already has bag item, Resource entry bag items emitted twice, or something like that since it doesn't seem to be specific to strings at all and can easily be confused with #315 with the current title.

niklashigi avatar Nov 30 '20 10:11 niklashigi

Thanks - I see what you mean. Reopened.

iBotPeaches avatar Nov 30 '20 11:11 iBotPeaches

Have experienced the same thing happening while recompiling Phonesky/PlayStore from here, making no changes.

--use-aapt2 fixes the issue but then I face a different problem, resource android:color/[...] is private. I suspect that one may be fixed by https://github.com/iBotPeaches/Apktool/pull/2650.

apktool 2.6.0

Investigated this as a by-product of triaging a different ticket - https://github.com/iBotPeaches/Apktool/issues/3098#issuecomment-1627478466

So I started a patch and it failed miserably.

➜  3098 apktool d com.instagram.android.apk -f -s
I: Using Apktool 2.7.1-7a22af-SNAPSHOT on com.instagram.android.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: /home/ibotpeaches/.local/share/apktool/framework/1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
W: Multiple bag attributes declared for item android:textColorHint
I: Copying raw classes.dex file...
I: Copying raw classes2.dex file...
I: Copying raw classes3.dex file...
I: Copying raw classes4.dex file...
I: Copying raw classes5.dex file...
I: Copying raw classes6.dex file...
I: Copying raw classes7.dex file...
I: Copying raw classes8.dex file...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
➜  3098 apktool b com.instagram.android
I: Using Apktool 2.7.1-7a22af-SNAPSHOT
I: Copying com.instagram.android classes.dex file...
I: Copying com.instagram.android classes2.dex file...
I: Copying com.instagram.android classes3.dex file...
I: Copying com.instagram.android classes5.dex file...
I: Copying com.instagram.android classes4.dex file...
I: Copying com.instagram.android classes7.dex file...
I: Copying com.instagram.android classes6.dex file...
I: Copying com.instagram.android classes8.dex file...
I: Checking whether resources has changed...
I: Building resources...
I: Copying libs... (/lib)
I: Copying libs... (/kotlin)
I: Building apk file...
I: Copying unknown files/dir...
I: Built apk into: com.instagram.android/dist/com.instagram.android.apk
➜  3098 

So while it worked for the issue apk, it failed in these regards.

  • tests failed
  • this is not an error for aapt2

So I fear I still have no true root understanding of why the duplicate bag items exist. It must act like a fallback mechanism so systems can leverage different types of values depending on the OS version.

However, take Instagram which has duplicate textColorHint. You'd think maybe the system resource was from a newer OS, but thats been in AOSP since API version 1.

    <style name="InThreadComposerTextArea">
       <item name="android:textColor">?textColorPrimary</item>
       <item name="android:textColorHint">?textColorTertiary</item>
       <item name="android:textColorHint">@color/igds_secondary_text</item>
       ...
    </style>

If the first issue was in 2018 and aapt2 came out in 2017 - I am starting to think this research is useless. Its clear that aapt2 doesn't care about this, so maybe we patch out the restriction in aapt1 and see how that handles as a test.

Once I get my aapt/aapt2 repos up to date - I'll work on that.

iBotPeaches avatar Jul 08 '23 21:07 iBotPeaches

Hacky workaround to aapt binary - https://github.com/iBotPeaches/platform_frameworks_base/commit/bc4ca278f3cb7fb10897310eb0ad0350a7dd0133

If this works with my only test of Instagram, going to go forward with it and close this.

iBotPeaches avatar Jul 08 '23 23:07 iBotPeaches

Did your hacky workaround to the aapt binary work on Instagram? It seems like the patch is in-place then for future versions of apktool?

fmresearchnovak avatar Jul 12 '23 15:07 fmresearchnovak

Yes to the extent that it compiled w/ no issue. Running on device I did not test.

iBotPeaches avatar Jul 12 '23 15:07 iBotPeaches