Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resource entry already has bag item (double entity) #1927

Closed
datdevs opened this issue Oct 28, 2018 · 19 comments · Fixed by #3130
Closed

Resource entry already has bag item (double entity) #1927

datdevs opened this issue Oct 28, 2018 · 19 comments · Fixed by #3130
Labels
Milestone

Comments

@datdevs
Copy link

datdevs commented Oct 28, 2018

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?
@Ibuprophen
Copy link

Ibuprophen commented Oct 28, 2018

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

@gsmmazhar
Copy link

any body know about this problem

@gsmmazhar
Copy link

i also faced this problem

@ingbrzy
Copy link

ingbrzy commented Oct 29, 2018

just delete doubles..

@gsmmazhar
Copy link

if we delete phone rebooting and stuck at bootloop

@gsmmazhar
Copy link

you test and try it

@iBotPeaches
Copy link
Owner

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

@gsmmazhar
Copy link

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

@gsmmazhar
Copy link

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\PIYAJE1\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\PIYAJE1\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
Copy link

@gsmmazhar
Copy link

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

@iBotPeaches
Copy link
Owner

Closing as duplicate - #315

@niklashigi
Copy link

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

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.

@iBotPeaches iBotPeaches changed the title Double string in styles.xml when i decompile framework-res Resource entry already has bag item (double entity) Nov 30, 2020
@iBotPeaches iBotPeaches reopened this Nov 30, 2020
@iBotPeaches
Copy link
Owner

Thanks - I see what you mean. Reopened.

@FriendlyNeighborhoodShane

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 #2650.

apktool 2.6.0

@iBotPeaches
Copy link
Owner

Investigated this as a by-product of triaging a different ticket - #3098 (comment)

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
Copy link
Owner

Hacky workaround to aapt binary - iBotPeaches/platform_frameworks_base@bc4ca27

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

@fmresearchnovak
Copy link

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?

@iBotPeaches
Copy link
Owner

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

@iBotPeaches iBotPeaches added this to the v2.8.0 milestone Jul 16, 2023
fmresearchnovak added a commit to fmresearchnovak/stigma that referenced this issue Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants