Apktool
Apktool copied to clipboard
[BUG]java.lang.ArrayIndexOutOfBoundsException when decompile apk
Information
- Apktool Version (
apktool -version) - 2.11.0 - Operating System (Mac, Linux, Windows) - Windows
- APK From? (Playstore, ROM, Other) - Apkpure
- Java Version (
java --version) - 22.0.1
Apktool version 2.10.0 has same issue, but version 2.9.3 works fine.
Stacktrace/Logcat
I: Using Apktool 2.11.0 on test.apk with 8 threads
I: Baksmaling classes.dex...
I: Baksmaling classes2.dex...
I: Copying raw assets/.wxxaawy.dex file...
I: Baksmaling classes3.dex...
I: Baksmaling classes4.dex...
I: Loading resource table...
I: Decoding file-resources...
I: Loading resource table from file: C:\Users\sss\AppData\Local\apktool\framework\1.apk
I: Decoding values */* XMLs...
I: Decoding AndroidManifest.xml with resources...
I: Regular manifest package...
Exception in thread "main" java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.ArrayIndexOutOfBoundsException: Index 10350680 out of bounds for length 129317
at brut.androlib.BackgroundWorker.waitForFinish(SourceFile:0)
at brut.androlib.ApkDecoder.decode(SourceFile:0)
at brut.apktool.Main.main(SourceFile:0)
Caused by: java.util.concurrent.ExecutionException: java.lang.ArrayIndexOutOfBoundsException: Index 10350680 out of bounds for length 129317
at java.base/java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.base/java.util.concurrent.FutureTask.get(FutureTask.java:191)
... 3 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 10350680 out of bounds for length 129317
at com.android.tools.smali.dexlib2.dexbacked.DexBuffer.readSmallUint(SourceFile)
at com.android.tools.smali.dexlib2.dexbacked.DexBackedDexFile.getMapItemForSection(SourceFile:0)
at com.android.tools.smali.dexlib2.dexbacked.DexBackedDexFile.<init>(SourceFile)
at com.android.tools.smali.dexlib2.dexbacked.ZipDexContainer.getEntries(SourceFile:0)
at com.android.tools.smali.dexlib2.dexbacked.ZipDexContainer.getDexEntryNames(SourceFile)
at brut.androlib.ApkDecoder.decodeSourcesSmaliJob(SourceFile:0)
at brut.androlib.ApkDecoder.lambda$decodeSourcesSmali$0(SourceFile)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
at java.base/java.lang.Thread.run(Thread.java:1570)
An error has occured.
Steps to Reproduce
apktool d test.apk -o test_decompile --only-main-classes
APK
APK link: https://pixeldrain.com/u/fhzaEige
This looks like an issue at smali - mind upstreaming this to them? https://github.com/google/smali
This looks like an issue at smali - mind upstreaming this to them? https://github.com/google/smali
Ok let me try, which smali version is used in apktool 2.9.3?
Ok let me try, which smali version is used in apktool 2.9.3?
3.0.3
Issue reported here https://github.com/google/smali/issues/88
I have a similar problem only it doesn't show up until I decompile, recompile, then try to decompile the recompiled apk a second time. (without any editing other than adding a few attributes). This is for the Google Pixel 6a SystemGoogle.apk.
./rebuild e:/3Custom14Pixelscript
rebuild is loading....
Unpacking e:/3Custom14Pixelscript/SystemUIGoogle.apk...
I: Using Apktool v2.11.0-3-4b2c9abe-SNAPSHOT on SystemUIGoogle.apk with 4 threads
I: Baksmaling classes.dex...
I: Loading resource table...
I: Baksmaling classes2.dex...
I: Decoding file-resources...
I: Loading resource table from file: framework-3Custom14Pixelscript\1.apk
I: Decoding values / XMLs...
I: Decoding AndroidManifest.xml with resources...
I: Regular manifest package...
I: Copying original files...
I: Copying lib...
I: Copying unknown files...
Rebuild only...
Added 5 lines to SystemUIGoogle/res/values/attrs.xml
Compiling first pass...
I: Using Apktool v2.11.0-3-4b2c9abe-SNAPSHOT on SystemUIGoogle.apk with 4 threads
I: Smaling smali folder into classes.dex...
I: Smaling smali_classes2 folder into classes2.dex...
I: Building resources with aapt2...
I: Copying original files...
I: Building apk file...
I: Importing lib...
I: Importing unknown files...
I: Built apk into: SystemUIGoogle\dist\SystemUIGoogle.apk
Decompiling first pass...
I: Using Apktool v2.11.0-3-4b2c9abe-SNAPSHOT on SystemUIGoogle.apk with 4 threads
I: Baksmaling classes.dex...
I: Loading resource table...
I: Baksmaling classes2.dex...
I: Decoding file-resources...
I: Loading resource table from file: framework-3Custom14Pixelscript\1.apk
I: Decoding values / XMLs...
I: Decoding AndroidManifest.xml with resources...
I: Regular manifest package...
Exception in thread "main" java.lang.RuntimeException: java.util.concurrent.ExecutionException: com.android.tools.smali.dexli
b2.util.DexUtil$InvalidFile: Unexpected container offset in header
at brut.androlib.BackgroundWorker.waitForFinish(BackgroundWorker.java:41)
at brut.androlib.ApkDecoder.decode(ApkDecoder.java:87)
at brut.apktool.Main.cmdDecode(Main.java:244)
at brut.apktool.Main.main(Main.java:105)
Caused by: java.util.concurrent.ExecutionException: com.android.tools.smali.dexlib2.util.DexUtil$InvalidFile: Unexpected cont
ainer offset in header
at java.util.concurrent.FutureTask.report(Unknown Source)
at java.util.concurrent.FutureTask.get(Unknown Source)
at brut.androlib.BackgroundWorker.waitForFinish(BackgroundWorker.java:39)
... 3 more
Caused by: com.android.tools.smali.dexlib2.util.DexUtil$InvalidFile: Unexpected container offset in header
at com.android.tools.smali.dexlib2.dexbacked.DexBackedDexFile.
Issue reported here google/smali#88
@iBotPeaches Can you please check this? https://github.com/google/smali/issues/88#issuecomment-2636033513 It seem not the smali issue, because I have skipped this
I: Copying raw assets/.wxxaawy.dex file...
but it have error when
I: Regular manifest package...
Ok let me try, which smali version is used in apktool 2.9.3?
3.0.3
@iBotPeaches Please check this when you have some free time.
Issue reported here google/smali#88
@iBotPeaches Can you please check this? google/smali#88 (comment) It seem not the smali issue, because I have skipped this
I: Copying raw assets/.wxxaawy.dex file...
but it have error when
I: Regular manifest package...
@iBotPeaches This issue still isn't resolved in latest commit.
@iBotPeaches I think I found the real problem here. I'm not sure if we need to fix this in apktool or in smali. https://github.com/google/smali/issues/88#issuecomment-3172294211