Apktool icon indicating copy to clipboard operation
Apktool copied to clipboard

[BUG] Chunk [end] is not a valid entry

Open Skylled opened this issue 3 years ago • 8 comments
trafficstars

Information

  1. Apktool Version (apktool -version) - 2.6.1
  2. Operating System (Mac, Linux, Windows) - Mac (also reproduced on Windows)
  3. APK From? (Playstore, ROM, Other) - Play Store

Stacktrace/Logcat

I: Using Apktool 2.6.1 on com.google.android.googlequicksearchbox_13.36.8.29.arm64.apk
I: Loading resource table...
Exception in thread "main" java.lang.IllegalArgumentException: Chunk [end] is not a valid entry
	at com.google.common.base.Preconditions.checkArgument(Preconditions.java:220)
	at com.google.common.base.Splitter$MapSplitter.split(Splitter.java:528)
	at brut.androlib.res.decoder.StringBlock$Tag.toString(StringBlock.java:167)
	at java.base/java.lang.String.valueOf(String.java:4213)
	at java.base/java.lang.StringBuilder.append(StringBuilder.java:173)
	at brut.androlib.res.decoder.StringBlock.processStyledString(StringBlock.java:260)
	at brut.androlib.res.decoder.StringBlock.getHTML(StringBlock.java:288)
	at brut.androlib.res.decoder.ARSCDecoder.readValue(ARSCDecoder.java:366)
	at brut.androlib.res.decoder.ARSCDecoder.readEntryData(ARSCDecoder.java:285)
	at brut.androlib.res.decoder.ARSCDecoder.readTableType(ARSCDecoder.java:261)
	at brut.androlib.res.decoder.ARSCDecoder.readTableTypeSpec(ARSCDecoder.java:184)
	at brut.androlib.res.decoder.ARSCDecoder.readTablePackage(ARSCDecoder.java:135)
	at brut.androlib.res.decoder.ARSCDecoder.readTableHeader(ARSCDecoder.java:84)
	at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:50)
	at brut.androlib.res.AndrolibResources.getResPackagesFromApk(AndrolibResources.java:783)
	at brut.androlib.res.AndrolibResources.loadMainPkg(AndrolibResources.java:64)
	at brut.androlib.res.AndrolibResources.getResTable(AndrolibResources.java:56)
	at brut.androlib.Androlib.getResTable(Androlib.java:70)
	at brut.androlib.ApkDecoder.getResTable(ApkDecoder.java:247)
	at brut.androlib.ApkDecoder.decode(ApkDecoder.java:109)
	at brut.apktool.Main.cmdDecode(Main.java:175)
	at brut.apktool.Main.main(Main.java:79)

Steps to Reproduce

  1. apktool d google-app.apk

Frameworks

If this APK is from an OEM ROM (Samsung, HTC, LG). Please attach framework files (.apks that live in /system/framework or /system/priv-app)

APK

If this APK can be freely shared, please upload/attach a link to it. We've only reproduced the issue on the latest builds of the Google Search app, and only on the 13.x.x.29 builds used by Pixel phones which presumably have different resources.

Last known-good version: https://www.apkmirror.com/apk/google-inc/google-search/google-search-13-35-9-release/google-app-13-35-9-29-arm64-2-android-apk-download/

Most recent known-bad version: https://www.apkmirror.com/apk/google-inc/google-search/google-search-13-37-9-release/google-app-13-37-9-29-arm64-2-android-apk-download/

Questions to ask before submission

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

Debugging details

My colleague was able to trace the string resource at fault to this one. However, we're not sure why there's now a problem as the same string also appears in the known-good version.

<string name="assistant_dictation_ineligible_android_old_version">To use Assistant voice typing, update your Android System. <a href=intent:#Intent;action=android.settings.SYSTEM_UPDATE_SETTINGS;end> Update </a> <br/><br/><a href=https://support.google.com/gboard/answer/11197787#update_app> Learn more </a></string>

Skylled avatar Sep 20 '22 21:09 Skylled

Possible duplicate of #2675

Skylled avatar Sep 20 '22 21:09 Skylled

thanks - I took a look and the actual string affected is this:

a;href=intent:#Intent;action=android.settings.SYSTEM_UPDATE_SETTINGS;end

This is double ;end is messing up the parser - going to have to research why that is.

iBotPeaches avatar Sep 21 '22 10:09 iBotPeaches

O apologies. That is literally the string you posted. I didn't scroll it left/right.

iBotPeaches avatar Sep 21 '22 11:09 iBotPeaches

Working app

➜  2890 aapt2 dump resources 2890-good.apk | grep 'SYSTEM_UPDATE'
      () "To use Assistant voice typing, update your Android System. <a href=intent:#Intent;action=android.settings.SYSTEM_UPDATE_SETTINGS;end>Update</a> <br> <br><a href=https://support.google.com/gboard/answer/11197787#update_app>Learn more</a>"
      (ca) "Per utilitzar l'escriptura per veu amb l'Assistent, actualitza el teu sistema Android. <a href="intent:#Intent;action=android.settings.SYSTEM_UPDATE_SETTINGS;end">Actualitza</a> <br> <br><a href="https://support.google.com/gboard/answer/11197787#update_app">Més informació</a>"

Broken app

➜  2890 aapt2 dump resources 2890.apk | grep 'SYSTEM_UPDATE'  
      () "To use Assistant voice typing, update your Android System. <a href=intent:#Intent;action=android.settings.SYSTEM_UPDATE_SETTINGS;end> Update </a> <br/><br/><a href=https://support.google.com/gboard/answer/11197787#update_app> Learn more </a>"
      (ca) (styled string) "Per utilitzar l'escriptura per veu amb l'Assistent, actualitza el teu sistema Android.  Actualitza   Més informació " a;href=intent:#Intent;action=android.settings.SYSTEM_UPDATE_SETTINGS;end:87,98 br:100,99 br:100,99 a;href=https://support.google.com/gboard/answer/11197787#update_app:100,115

Lots o differences. @IgorEisberg any idea how we could patch the splitter to handle basically intent based urls? Sadly I noticed the test suite has basically no coverage for these type of URLs.

iBotPeaches avatar Sep 21 '22 11:09 iBotPeaches

Got the same issue, got any progress?

egor-eremeev avatar May 16 '23 11:05 egor-eremeev

Any progress here ?

0x4c756e61 avatar Mar 17 '24 10:03 0x4c756e61

@iBotPeaches I checked both files I may miss something or files changed now ? Here is md5 for files i downloaded:

  • 083a2f6c0bb7594d96f4badcbafa5dd2 13-35-9
  • 50d04b19142e064adc5578a087546dce 13-37-9

Here is what I get for string containing SYSTEM_UPDATE_SETTINGS

  • 13-35-9 Styles count = 4506, String index = 26094
  • 13-37-9 Styles count = 6288, String index = 27560

So this string on both files is NOT styled string, why are you trying to process it as styled string ?

BTW: Forgive me I am a strong hater of guava & kotlin, both useless worms.

REAndroid avatar May 24 '24 10:05 REAndroid

@REAndroid - Good question, I guess you get so focused on something you might overlook the fact you are mistyping it as styled.

iBotPeaches avatar May 27 '24 15:05 iBotPeaches