[UTIL][JAN 20, 2024] Apktool - Tool for reverse engineering apk files

Search This thread

hillz

Senior Member
Jun 10, 2012
285
35
Indonesia
Guys I'm getting this error when trying to decompile an apk "Exception in thread "main" java.lang.IndexOutOfBoundsException"

Code:
[linux@x apk]$ apktool d myapp.apk 
I: Using Apktool 2.3.1 on myapp.apk 
I: Loading resource table...
Exception in thread "main" java.lang.IndexOutOfBoundsException
        at java.nio.ByteBuffer.wrap(ByteBuffer.java:375)
        at brut.androlib.res.decoder.StringBlock.decodeString(StringBlock.java:297)
        at brut.androlib.res.decoder.StringBlock.getString(StringBlock.java:110)
        at brut.androlib.res.decoder.StringBlock.getHTML(StringBlock.java:126)
        at brut.androlib.res.decoder.ARSCDecoder.readValue(ARSCDecoder.java:341)
        at brut.androlib.res.decoder.ARSCDecoder.readEntryData(ARSCDecoder.java:257)
        at brut.androlib.res.decoder.ARSCDecoder.readTableType(ARSCDecoder.java:233)
        at brut.androlib.res.decoder.ARSCDecoder.readTableTypeSpec(ARSCDecoder.java:156)
        at brut.androlib.res.decoder.ARSCDecoder.readTablePackage(ARSCDecoder.java:118)
        at brut.androlib.res.decoder.ARSCDecoder.readTableHeader(ARSCDecoder.java:80)
        at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:47)
        at brut.androlib.res.AndrolibResources.getResPackagesFromApk(AndrolibResources.java:599)
        at brut.androlib.res.AndrolibResources.loadMainPkg(AndrolibResources.java:73)
        at brut.androlib.res.AndrolibResources.getResTable(AndrolibResources.java:65)
        at brut.androlib.Androlib.getResTable(Androlib.java:68)
        at brut.androlib.ApkDecoder.setTargetSdkVersion(ApkDecoder.java:228)
        at brut.androlib.ApkDecoder.decode(ApkDecoder.java:118)
        at brut.apktool.Main.cmdDecode(Main.java:163)
        at brut.apktool.Main.main(Main.java:72)

You can download the app here https://www.dropbox.com/s/fas9ni28tpt9gzx/myapp.apk?dl=0
How do I solve this ?
 
Guys I'm getting this error when trying to decompile an apk...
Try using one of the previous Apktool.jar releases and see if it provides the same results after decompiling...


~~~~~~~~~~~~~~~
I DO NOT provide support via PM unless asked/requested by myself. PLEASE keep it in the threads where everyone can share.
 

hillz

Senior Member
Jun 10, 2012
285
35
Indonesia
Try using one of the previous Apktool.jar releases and see if it provides the same results after decompiling...


~~~~~~~~~~~~~~~
I DO NOT provide support via PM unless asked/requested by myself. PLEASE keep it in the threads where everyone can share.

it provides the same results, can you please try decoding it for me ?
 

Spannaa

Recognized Contributor / Themer
Sep 13, 2010
7,431
16,793
Cardiff
Huawei Nexus 6P
Google Pixel 6
Guys I'm getting this error when trying to decompile an apk "Exception in thread "main" java.lang.IndexOutOfBoundsException"

Code:
[linux@x apk]$ apktool d myapp.apk 
I: Using Apktool 2.3.1 on myapp.apk 
I: Loading resource table...
Exception in thread "main" java.lang.IndexOutOfBoundsException
        at java.nio.ByteBuffer.wrap(ByteBuffer.java:375)
        at brut.androlib.res.decoder.StringBlock.decodeString(StringBlock.java:297)
        at brut.androlib.res.decoder.StringBlock.getString(StringBlock.java:110)
        at brut.androlib.res.decoder.StringBlock.getHTML(StringBlock.java:126)
        at brut.androlib.res.decoder.ARSCDecoder.readValue(ARSCDecoder.java:341)
        at brut.androlib.res.decoder.ARSCDecoder.readEntryData(ARSCDecoder.java:257)
        at brut.androlib.res.decoder.ARSCDecoder.readTableType(ARSCDecoder.java:233)
        at brut.androlib.res.decoder.ARSCDecoder.readTableTypeSpec(ARSCDecoder.java:156)
        at brut.androlib.res.decoder.ARSCDecoder.readTablePackage(ARSCDecoder.java:118)
        at brut.androlib.res.decoder.ARSCDecoder.readTableHeader(ARSCDecoder.java:80)
        at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:47)
        at brut.androlib.res.AndrolibResources.getResPackagesFromApk(AndrolibResources.java:599)
        at brut.androlib.res.AndrolibResources.loadMainPkg(AndrolibResources.java:73)
        at brut.androlib.res.AndrolibResources.getResTable(AndrolibResources.java:65)
        at brut.androlib.Androlib.getResTable(Androlib.java:68)
        at brut.androlib.ApkDecoder.setTargetSdkVersion(ApkDecoder.java:228)
        at brut.androlib.ApkDecoder.decode(ApkDecoder.java:118)
        at brut.apktool.Main.cmdDecode(Main.java:163)
        at brut.apktool.Main.main(Main.java:72)

You can download the app here https://www.dropbox.com/s/fas9ni28tpt9gzx/myapp.apk?dl=0
How do I solve this ?

Same error here with apktool 2.3.1 & a newly built apktool 2.3.2 snapshot.

If you just want to see what's inside the Lazada apk, JADX can read most of the resources.
 
  • Like
Reactions: Thebear j koss
I'm seeing an odd issue decompiling Samsung Oreo apk's. The layouts aren't decompiling correctly. See screenshots. V21 v11 and v26 missing but the decompiled layouts folder has more layouts then original. So I'm assuming it's merging them to one layout.

First screenshots left decompiled right apk extracted layouts.

Other screen shows more layouts in decompiled then original.

Anyone else see this? Apk tool 224
 

Attachments

  • 20180328_143156.jpg
    20180328_143156.jpg
    265.7 KB · Views: 195
  • IMG_20180328_142731_669.jpg
    IMG_20180328_142731_669.jpg
    116.8 KB · Views: 196

Thebear j koss

Senior Member
I'm seeing an odd issue decompiling Samsung Oreo apk's. The layouts aren't decompiling correctly. See screenshots. V21 v11 and v26 missing but the decompiled layouts folder has more layouts then original. So I'm assuming it's merging them to one layout.

First screenshots left decompiled right apk extracted layouts.

Other screen shows more layouts in decompiled then original.

Anyone else see this? Apk tool 224
Stop theming samsung. Lol

Sent from my Moto G5S Plus using Thebear Blue XDA Labs
 

edzamber

Senior Member
Feb 21, 2012
3,916
3,712
Hi all,

Maybe someone have an idea...

I tryed to decompil last Playstore 9.4.18 with AOSP framework 9.0 api 28 and original signature.

No problem, i make changes into ressources.arsc, recompil perfectly.

But my apk is corrupted. If i try to Remove or add something in recompiled apk with 7zip,i have "non implemented" pop-up.

My drawables Folders as drawable-hdpi-v4 in original apk are rename drawable-hdpi and i have a FC.


I have only modify values-fr.

My File res/drawable-xxhdpi/drawer_shadow.9.png is present ...

Here my FC log :
Code:
FATAL EXCEPTION: main
Process: com.android.vending, PID: 12137
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.vending/com.google.android.finsky.activities.MainActivity}: android.view.InflateException: Binary XML file line #1: Binary XML file line #1: Error inflating class com.google.android.finsky.layout.play.FinskyDrawerLayout
  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java)
  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java)
  at android.app.ActivityThread.-wrap14(ActivityThread.java)
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java)
  at android.os.Handler.dispatchMessage(Handler.java)
  at android.os.Looper.loop(Looper.java)
  at android.app.ActivityThread.main(ActivityThread.java)
  at java.lang.reflect.Method.invoke(Native Method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
Caused by: android.view.InflateException: Binary XML file line #1: Binary XML file line #1: Error inflating class com.google.android.finsky.layout.play.FinskyDrawerLayout
Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class com.google.android.finsky.layout.play.FinskyDrawerLayout
Caused by: java.lang.reflect.InvocationTargetException
  at java.lang.reflect.Constructor.newInstance0(Native Method)
  at java.lang.reflect.Constructor.newInstance(Constructor.java)
  at android.view.LayoutInflater.createView(LayoutInflater.java)
  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java)
  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java)
  at android.view.LayoutInflater.inflate(LayoutInflater.java)
  at android.view.LayoutInflater.inflate(LayoutInflater.java)
  at android.view.LayoutInflater.inflate(LayoutInflater.java)
  at android.support.v7.app.aq.b(SourceFile:77)
  at android.support.v7.app.aa.setContentView(SourceFile:21)
  at com.google.android.finsky.activities.MainActivity.onCreate(SourceFile:30)
  at android.app.Activity.performCreate(Activity.java)
  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java)
  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java)
  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java)
  at android.app.ActivityThread.-wrap14(ActivityThread.java)
  at android.app.ActivityThread$H.handleMessage(ActivityThread.java)
  at android.os.Handler.dispatchMessage(Handler.java)
  at android.os.Looper.loop(Looper.java)
  at android.app.ActivityThread.main(ActivityThread.java)
  at java.lang.reflect.Method.invoke(Native Method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
Caused by: android.content.res.Resources$NotFoundException: Drawable com.android.vending:drawable/drawer_shadow with resource ID #0x7f0800cc
Caused by: android.content.res.Resources$NotFoundException: File res/drawable-xxhdpi/drawer_shadow.9.png from drawable resource ID #0x7f0800cc
  at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java)
  at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java)
  at android.content.res.Resources.getDrawable(Resources.java)
  at android.content.Context.getDrawable(Context.java)
  at android.support.v4.content.d.a(SourceFile:16)
  at com.google.android.play.drawer.g.<initSourceFile:7)
  at com.google.android.finsky.layout.play.FinskyDrawerLayout.<initSourceFile:3)
  at java.lang.reflect.Constructor.newInstance0(Native Method)
  at java.lang.reflect.Constructor.newInstance(Constructor.java)
  at android.view.LayoutInflater.createView(LayoutInflater.java)
  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java)
  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java)

Here AOSP framework 9.0 if someone want to test...

https://www.mediafire.com/download/dgvmdq6jc861nud
 

Thebear j koss

Senior Member
Hi all,

Maybe someone have an idea...

I tryed to decompil last Playstore 9.4.18 with AOSP framework 9.0 api 28 and original signature.

No problem, i make changes into ressources.arsc, recompil perfectly.

But my apk is corrupted. If i try to Remove or add something in recompiled apk with 7zip,i have "non implemented" pop-up.

My drawables Folders as drawable-hdpi-v4 in original apk are rename drawable-hdpi and i have a FC.


I have only modify values-fr.

My File res/drawable-xxhdpi/drawer_shadow.9.png is present ...

Here my FC log :


Here AOSP framework 9.0 if someone want to test...

https://www.mediafire.com/download/dgvmdq6jc861nud
What happens with no changes? Does it build and install? Are you trying to change that drawer shadow? From the log it looks like it is reading 2 versions of that resource. Do you have that as an xml or color as well as the png somewhere?

Sent from my Moto G5S Plus using Thebear Blue XDA Labs
 

edzamber

Senior Member
Feb 21, 2012
3,916
3,712
What happens with no changes? Does it build and install? Are you trying to change that drawer shadow? From the log it looks like it is reading 2 versions of that resource. Do you have that as an xml or color as well as the png somewhere?
If i decompil and recompil without any changes, its the same problem... I have look about drawer shadow
with textscrawler but nothing match except png. I Wonder if there is not a security protection from Google in New Playstore 9.4.18. I havn't Any issue with 9.2.32.
 
Last edited:
  • Like
Reactions: Thebear j koss
If i decompil and recompil without any changes, its the same problem... I have look about drawer shadow with textscrawler but nothing match except png. I Wonder if there is not a security protection from Google in New Playstore 9.4.18. I havn't Any issue with 9.2.32.
To be honest...

I know something is different with the newer Play Store because I use an older version and, until recently, I was able to submit feedback and now I can't. Everything else works still but, that.


~~~~~~~~~~~~~~~
I DO NOT provide support via PM unless asked/requested by myself. PLEASE keep it in the threads where everyone can share.
 

iBotPeaches

Recognized Developer
Apr 8, 2011
951
4,500
Tampa
connortumbleson.com
Time for my ever so-often update for the crowd here. This morning I merged a feature that fixed a Windows issue with commands becoming too long. This happens with applications built by Unity (and others), as assets are frequently stored or compressed which Apktool needs to know about. Apktool then passes a command to aapt which is sometimes upwards of 3,000 characters in length. Windows is the only operating system that has a problem about this. I did a solid amount of research (#1 / #2 / #3) in hopes to "stage" the steps that aapt does. This would allow Windows to work around the small limitation it has when it comes to commands.

I ended up building my own "apk" builder, which was nothing more than a glorified .zip creator. It took compression type into account when adding files into the application. The problem is that you can't modify the compression type of a file in a zip easily using only aapt. The options are basically, remove that file and then re-add it with the compression type you prefer. So if I accidentally built the application with a compressed "ic_sysbar_back_carmode.webp" file, then I needed to remove that file before I attempted adding it again in the STORED format. This took some engineering, hence why the pull request ended up changing a good deal of code. I basically don't add files to the application that I intend to add manually without compression. It finally worked and I was excited, it passed all testing and was merged.

Unfortunately, success was short-lived. As a side affect of now storing the entire directory path of the file, we included the directory the asset in question was from. In the example above this was "SystemUI/res/drawable-ldrtl-xxhdpi-v4/ic_sysbar_back_carmode.webp".

Apktool works by decoding the resources.arsc which leads to decoding each configuration in the application and finding resources in that configuration. We can see that the configuration above is "ldrtl-xxhdpi-v4", but aapt and by extension Apktool don't see the "v4" portion.
➜ Bug1761 aapt d configurations SystemUI.apk | grep 'ldrtl-xxxhdpi'
ldrtl-xxxhdpi
This is because "v4" is an implicit sdk version added by the aapt binary. No one building this example application added that qualifier, it was automatic. Here comes the problem. The 56 byte header for that qualifier does not list anything about an SDK version. It only tells me "ldtrl" and "xxhdpi", if the qualifiers used were from API21 like "notround", then its obvious to know a SDK level should be added. This qualifier was added by aapt/aapt2 because it scanned a massive hardcoded list of attributes in order to determine what qualifier that resource should be under. It actually does this crazy thing and "strip" resources to versioned qualifiers on its own. The long story is Apktool does not read the file (AXML) to determine the attributes used, so it cannot determine this. It might be able too in the future, but Java is not blazing speed low level C++. It would have to use like an XML reader (PullParser) to read each attribute. It therefore, currently, drops those version qualifiers unless they were explicitly provided. This means an uncompressed asset is recorded in file-system, but then the qualifier processed file-path is different (missing the implicit version qualifier).

This means my patch broke lots of applications (None of which that were in testing). This caused errors like
java.io.FileNotFoundException: SystemUI/res/drawable-ldrtl-xxhdpi-v4/ic_sysbar_back_carmode.webp (No such file or directory)
So I had to revert the fix. This means Windows support for large application is still broken. It means that version v2.3.2 will have a release this weekend, but not with all the intended features I hoped. I apologize and we will fix these in time.
 

iBotPeaches

Recognized Developer
Apr 8, 2011
951
4,500
Tampa
connortumbleson.com
A new version has been released!

v2.3.2 (Released April, 7, 2018)

  • [#1742] - Android P Preview Support
  • [#1689] - Initial support for rebuilding with aapt2 binary
  • [#1730] - Fixed issue with application with empty resources.arsc file
  • [#1703] - Fixed issue with root depth kotlin folder
  • [#1741] - Fixed building Apktool on Windows.
  • Added warning if application is non-zero typeIdOffset is discovered.
  • Update to baksmali v2.2.2
  • Support for treating additional photo extensions as raw (m4a)
  • Prevent temporary BRUT files from clogging temp directories.

Download: https://bitbucket.org/iBotPeaches/apktool/downloads/apktool_2.3.2.jar
md5 - 953ed8a553becac4e713d1073912f15f
sha256 - 648dba910d49365d78665f7060935802f4187d5529064e16caf34eee06cb5207

Details of Release: https://connortumbleson.com/2018/04/07/apktool-v2-3-2-released/
 

danyldft

Senior Member
Oct 5, 2013
158
50

kos25k

Senior Member
Nov 15, 2012
3,197
444
hello and happy Easter!Newbie here.(to be honest I never used apktool) So i'll tell my story and I would be really very thankful if someone could help me.So,I bought a prerooted Vorke Z6 tv box.But the problem is that the tv app from my provider that I pay monthly,doesn't run cause it detects root.I tryied rootcloack xposed module but it doesn't work.The decoder is on my father on the 1st floor so I can only use the app to watch tv.So I would love a kindful dude to decompile my app not to detect root.or at least someone to tell me a working method to do myself.Here is my app.I hope for help.Thanks.
https://drive.google.com/file/d/1RQ4ThmKHkz9tucgIpDj1OXMUVVNLxd8M/view?usp=drivesdk
 
hello and happy Easter!Newbie here.(to be honest I never used apktool) So i'll tell my story and I would be really very thankful if someone could help me.So,I bought a prerooted Vorke Z6 tv box.But the problem is that the tv app from my provider that I pay monthly,doesn't run cause it detects root.I tryied rootcloack xposed module but it doesn't work.The decoder is on my father on the 1st floor so I can only use the app to watch tv.So I would love a kindful dude to decompile my app not to detect root.or at least someone to tell me a working method to do myself.Here is my app.I hope for help.Thanks.
https://drive.google.com/file/d/1RQ4ThmKHkz9tucgIpDj1OXMUVVNLxd8M/view?usp=drivesdk

There is no guide or anything to fix this, you need to hide root in the system. Magisk and SuperSU can do this already. Try using one of those to root if possible. Otherwise you might be stuck.
 

Top Liked Posts