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
[BUG] ArrayIndexOutOfBoundsException exception for APK without resources produced with AGP7 #2701
Comments
Extra clarification - in case of AGP < 7 resources.arsc after decoding contains only:
so essentially it is empty. |
Brain is blanking - what is AGP? GooglePlay something? |
Android Gradle Plugin |
To save me time, can you share those two applications or even push the test source via PR to this repo under 2701? https://github.com/iBotPeaches/TestApks |
I see the same exception when I use Apktool on any recent "Android Instrumented Test" APK. I assume inez's APK is also a instrumented test APK based on the "-androidTest" in the file name. For example, you can use an APK from the latest Android CTS release, like android-cts/testcases/AlarmTestApp.apk in https://dl.google.com/dl/android/cts/android-cts-12_r2-linux_x86-arm.zip Alternatively, you can create a new test app in Android Studio, using the default template for Phone App with Empty Activity, then open the auto-generated "ExampleInstrumentedTest" and click on the "Run test" triangle in the margin next to the class name. That will generate the APK in app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk |
Just leaving a note that I attempted to build my own application for replication, kept getting manifest merge errors with a brand new empty application and gave up. I will return back to this ticket in time. |
Can you give this a try? gramound/TestApks@6f1f747 |
Until we figure this out, could we add a "case 0: pkg = null; break;" to loadMainPkg, such that we'd jump to the more meaningful exception "arsc files with zero packages or no arsc file found." instead of crashing inside selectPkgWithMostResSpecs? |
@gramound - Pulled in your test app - thanks as well as fixing source to crash at right location as you mentioned. Have not peeked yet further at this time. |
@inez - Does adding |
On second thought The issue with this empty resources.arsc is that apktool can't find the main package name. Is there an alternate way of finding it?
|
Actually, prehaps injecting a default bogus package name could be good enough in that situation? I had accidentally left the code snippet above in my build and was having no problem decompiling a whole bunch of apks that had nothing to do with the injected package name. Everything went fine. The only impact was the |
I'll admit this ticket really confused me at first, but after another look. We are building the test sample which must be some shell of the application to trigger tests. So have a patch going up that properly survives decoding with an empty resource table. You'll basically get nothing because the resource table is basically nothing.
I extracted the sample apk from the test apk pr, updated gradle here and loaded into test suite. Will close on merge of: #3230 Sorry for delay. |
Thanks! I just want to clarify we don't get nothing. We actually get the decompiled test source code (e.g. smali_classes3/com/ibotpeaches/issue2701/ExampleInstrumentedTest.smali) |
Information
apktool -version
) - 2.6.0Stacktrace/Logcat
Steps to Reproduce
apktool -f d demo-app-debug-androidTest.apk
APK produced with AGP < 7:
APK produced with AGP 7
The text was updated successfully, but these errors were encountered: