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

Search This thread

ilie321

Senior Member
Feb 5, 2011
452
270
41
I'd need the APK to do any real debugging. I fixed one of those errors a couple days ago, but it was a real hacky fix and not something I wish to replicate.

Something in ResSpec is mis-identifying some of these resources which is causing the cast to fail because you obviously can't cast a ResFileValue to a ScalarValue.

any news ? thanks
 

fisha21

Senior Member
Nov 23, 2007
2,331
4,379
Whilst I am at it, I was wondering if you might be able to tell me where we are going wrong with recompiling the phone.apk from AOSP 4.1.2 (not 4.2) using apktool_1.5.0.jar

Interestingly, I get the exact same errors trying to recompile Phone.apk from an HTC 4.1 ROM....didn't realise they both used the same phone apk.

Did try fixing the referenced xmls, but will have to take a closer look at those % symbols..

Sent from my HTC One X using xda premium
 

tenasama

Member
May 6, 2010
29
26
Fuzhou
You gave me the link to an APK on the Market. Sorry, I don't have time to chase after it and download it, pull it from phone and then work on it. You have to meet me half way :)

4.2 is at AOSP now. Working on some updates.

May I ask how to decompile apk with out debug info in smali files?
(like .line XXX)

I've used option codes like -b or --no-debug-info but it shows wrong options…

Thanks~

PS:I'm using apktool v1.5.0~
 
  • Like
Reactions: mateorod

M4gicM@

Senior Member
May 3, 2010
59
89
Internet
Pls help me with this problem: in apktool when I am trying to get resources to translate menus in baidu input
i get this error:
I have tried a lot of apktool versions and also framework apk even from roms that says baidu works but no succes
I do something wrong?

This is most likely because you are on a 64bit machine. Try uname - a to verify. aapt is a 32bit binary so you will need to get the approprite i386 libs to run.

type this
Code:
sudo apt-get update
sudo apt-get install ia32-libs

this will fix the errors where you get the result
Code:
bash: /aapt: No such file or directory
 
  • Like
Reactions: ilie321

iBotPeaches

Recognized Developer
Apr 8, 2011
951
4,500
Tampa
connortumbleson.com
I was wondering if anyone had experience with Proguard. Trying to get it to work with Gradle but no luck. Apktool is like 9MB now, due to my extra /libs when I only use like 2MB of those libraries so I don't need them all merged into the final jar, but can't figure how out to make this work correctly.

Unless people want a 9MB Apktool v1.5.1 lol
 

iBotPeaches

Recognized Developer
Apr 8, 2011
951
4,500
Tampa
connortumbleson.com
Here is pre-release of Apktool v1.5.1

If you don't know how to use this, then don't. Simple as that.

https://github.com/downloads/iBotPeaches/Apktool/apktool-cli-1.5.1-SNAPSHOT.jar

v1.5.1 Pre-Release 1
  • Updated smali/baksmali to v1.4.0
  • Fixed reference-array problem (BurgerZ)
  • Fixed bad spacing issue on Mac OS X
  • Removed maven in favor of gradle
  • Removed Maven REPOs that were used if local projects didn’t exist.
  • Merged brut.j.dir,brut.j.common,brut.j.util & brut.apktool.smali (Fork of JesusFreke’s smali) into one repo.
  • Fix –verbose mode to actually work
  • Added SDK API 17 framework
  • Don’t decompile public.xml (have aapt regenerate it based on resources). - REMOVED
  • Added -o / –original flag to retain system APK signature and inject contents into APK - DELAYED
 

ilie321

Senior Member
Feb 5, 2011
452
270
41
This is most likely because you are on a 64bit machine. Try uname - a to verify. aapt is a 32bit binary so you will need to get the approprite i386 libs to run.

type this
Code:
sudo apt-get update
sudo apt-get install ia32-libs

this will fix the errors where you get the result
Code:
bash: /aapt: No such file or directory

thanks i tested this on win xp sp3 x86 same error
 

CosmicDan

Senior Member
Jun 19, 2009
5,906
7,746
37
Sydney
Xiaomi Poco X3 Pro
thanks i tested this on win xp sp3 x86 same error

"No such file or directory" means there is no such file or directory. Make sure the path is correct or that you've added the location of aapt to the PATH in bash. Are you using GnuWin32 or Cygwin? I'm not sure if you can use the linux aapt binary with Cygwin.

Either way, if it was an architecture or binary issue, it would show "could not execute aapt" instead of "no such file or directory".

If the errors shows "/aapt" I think it's looking for it in root, change it to ./aapt for current working folder. But best practice is to put it somewhere in your PATH - for GnuWin32 that'd be system32 or for cygqwin that'd be cygwin/usr/bin/ (I think).
 

prabhjots

Senior Member
Jul 7, 2012
492
115
Toronto
Excuse me if I'm asking stupid questions, I'm a newbie to Android Dev.

Am I right in saying that the tool doesn't currently work with Android 4.2 APKs? I tried decompiling, editing (trying to add a new language dictionary) and recompiling the 4.2 Android Keyboard. But it wouldn't compile.
The error
Code:
I: Loaded.
I: Decoding file-resources...
I: Decoding values*/* XMLs...
I: Done.
I: Copying assets and libs...
I: Checking whether sources has changed...
I: Smaling...
I: Checking whether resources has changed...
I: Building resources...
D:\apktool\LatinImeGoogle_signed.apk\res\layout\more_suggestions.xml:4: error: No resource identifier found for attribute 'keyLetterSize' in package 'com.android.inputmethod.latin'
D:\apktool\LatinImeGoogle_signed.apk\res\layout\more_suggestions.xml:4: error: No resource identifier found for attribute 'keyLabelSize' in package 'com.android.inputmethod.latin'
D:\apktool\LatinImeGoogle_signed.apk\res\layout\more_suggestions.xml:4: error: No resource identifier found for attribute 'keyHintLetterRatio' in package 'com.android.inputmethod.latin'
and so on it goes for the entire list of resources.

Is there something I'm doing wrong?

Next, I tried changing the package name in AndroidManifest.xml from:
Code:
<manifest android:versionCode="1700" android:versionName="JellyBeanMR1-448013" coreApp="true" package="com.google.android.inputmethod.latin"
  xmlns:android="http://schemas.android.com/apk/res/android">

to
Code:
<manifest android:versionCode="1700" android:versionName="JellyBeanMR1-448013" coreApp="true" package="com.android.inputmethod.latin"
  xmlns:android="http://schemas.android.com/apk/res/android">

and then the compile works correctly.

however, the size of the new apk now becomes around 8.7 MB instead of the original 12 MB. This, despite adding a 400 KB .dict file.

Am I doing something wrong?
 

pakjebakmeel

Senior Member
Apr 26, 2012
177
92
Ankeveen
Ok, so when trying to install the framework-res.apk from the factory image v4.2 (TAKJU/JOP40C) using the version from post #828 in this thread:

Code:
java -Xmx256M -jar ~/Downloads/apktool-cli-1.5.1-SNAPSHOT.jar if ~/Downloads/framework-res.apk

Code:
Exception in thread "main" brut.androlib.AndrolibException: Multiple resources: spec=0x01080291 drawable/ic_ab_back_holo_dark, config=-xhdpi
	at brut.androlib.res.data.ResConfig.addResource(ResConfig.java:65)
	at brut.androlib.res.data.ResConfig.addResource(ResConfig.java:58)
	at brut.androlib.res.decoder.ARSCDecoder.readEntry(ARSCDecoder.java:197)
	at brut.androlib.res.decoder.ARSCDecoder.readConfig(ARSCDecoder.java:166)
	at brut.androlib.res.decoder.ARSCDecoder.readType(ARSCDecoder.java:131)
	at brut.androlib.res.decoder.ARSCDecoder.readPackage(ARSCDecoder.java:106)
	at brut.androlib.res.decoder.ARSCDecoder.readTable(ARSCDecoder.java:83)
	at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:49)
	at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:40)
	at brut.androlib.res.AndrolibResources.installFramework(AndrolibResources.java:459)
	at brut.androlib.Androlib.installFramework(Androlib.java:491)
	at brut.apktool.Main.cmdInstallFramework(Main.java:219)
	at brut.apktool.Main.main(Main.java:74)

Or:

Code:
java -Xmx256M -jar ~/Downloads/apktool-cli-1.5.1-SNAPSHOT.jar d ~/Downloads/framework-res.apk ~/Downloads/framework-res

Code:
I: Loading resource table...
Exception in thread "main" brut.androlib.AndrolibException: Multiple resources: spec=0x01080291 drawable/ic_ab_back_holo_dark, config=-xhdpi
	at brut.androlib.res.data.ResConfig.addResource(ResConfig.java:65)
	at brut.androlib.res.data.ResConfig.addResource(ResConfig.java:58)
	at brut.androlib.res.decoder.ARSCDecoder.readEntry(ARSCDecoder.java:197)
	at brut.androlib.res.decoder.ARSCDecoder.readConfig(ARSCDecoder.java:166)
	at brut.androlib.res.decoder.ARSCDecoder.readType(ARSCDecoder.java:131)
	at brut.androlib.res.decoder.ARSCDecoder.readPackage(ARSCDecoder.java:106)
	at brut.androlib.res.decoder.ARSCDecoder.readTable(ARSCDecoder.java:83)
	at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:49)
	at brut.androlib.res.AndrolibResources.getResPackagesFromApk(AndrolibResources.java:390)
	at brut.androlib.res.AndrolibResources.loadMainPkg(AndrolibResources.java:56)
	at brut.androlib.res.AndrolibResources.getResTable(AndrolibResources.java:48)
	at brut.androlib.Androlib.getResTable(Androlib.java:54)
	at brut.androlib.ApkDecoder.getResTable(ApkDecoder.java:170)
	at brut.androlib.ApkDecoder.decode(ApkDecoder.java:99)
	at brut.apktool.Main.cmdDecode(Main.java:135)
	at brut.apktool.Main.main(Main.java:70)
 
Last edited:

CosmicDan

Senior Member
Jun 19, 2009
5,906
7,746
37
Sydney
Xiaomi Poco X3 Pro
Dude if you saw iBot's last post, 1.5.1 has not been updated for 4.2 yet. It only recently hit AOSP so you'll have to wait.

Sent from Xperia Play (R800a) on Turbo UI with Tapatalk
 

pakjebakmeel

Senior Member
Apr 26, 2012
177
92
Ankeveen
Dude if you saw iBot's last post, 1.5.1 has not been updated for 4.2 yet. It only recently hit AOSP so you'll have to wait.

Sent from Xperia Play (R800a) on Turbo UI with Tapatalk

Thanks, well it said:

4.2 is at AOSP now. Working on some updates.

and some time after he said:

Added SDK API 17 framework

So I thought it supported the latest 4.2 with that API level 17. Probably my bad but it sounded like it was supposed to work now.
 
Last edited:
  • Like
Reactions: Q9Nap

paulobrien

Senior Member
Nov 6, 2003
5,276
7,321
Norwich
www.MoDaCo.com
Good afternoon folks.

I've made a super-quick change to fix the issue with duplicate resources in 4.2, which is actually caused by the additional support for RTL languages.

- You can view my changes in this commit - https://github.com/paulobrien/Apktool/commit/6e4c8ffb23e91d7924273d882196961633988718
- I have submitted a pull request here - https://github.com/iBotPeaches/Apktool/pull/63
- You can download and build yourself in the interim from my github - https://github.com/paulobrien/Apktool

P
 

CosmicDan

Senior Member
Jun 19, 2009
5,906
7,746
37
Sydney
Xiaomi Poco X3 Pro
Nice work Paul.

Yes the new apktool adds support for SDK version 17, but in case you didn't notice it is marked as preview release.

Sent from Xperia Play (R800a) on Turbo UI with Tapatalk
 

iBotPeaches

Recognized Developer
Apr 8, 2011
951
4,500
Tampa
connortumbleson.com
Thanks for the help.

Upon first glance (now that the dev docs have updated). We are dealing with just a couple of new resources/configs. I'll probably check aapt itself though, as sometimes Android doesn't keep their docs up to date :/

Density
public static final int DENSITY_DPI_UNDEFINED - 0 (0x00000000)
Layout
public static final int SCREENLAYOUT_LAYOUTDIR_LTR - 64 (0x00000040)
public static final int SCREENLAYOUT_LAYOUTDIR_MASK - 192 (0x000000c0)
public static final int SCREENLAYOUT_LAYOUTDIR_RTL - 128 (0x00000080)
public static final int SCREENLAYOUT_LAYOUTDIR_SHIFT - 6 (0x00000006)
public static final int SCREENLAYOUT_LAYOUTDIR_UNDEFINED - 0 (0x00000000)


With new configs of...
public int densityDpi

EDIT: Also 2 configurations were deprecated. Don't know if it really matters if we remove them in Apktool, but I'll figure it out later.
public static final int ORIENTATION_SQUARE
public static final int TOUCHSCREEN_STYLUS


I will take a peek into aapt to see how the order of the new localizations should be done and get an update out. I'll use Paul's pull as a base, and add the remaining resource flags in. Then we will have a PR2, then I'll try and get Proguard working. Then public release of v1.5.1.

I also got my hands on a OPPO Finder ROM and that ROM has its own configs that require its own customized aapt for building. I'll see about getting source DIFFs from them (OPPO Chinese Company) to expand Apktool to support that strange company that doesn't abide by Android standards.



JesusFreke is also re-doing dexlib for smali, but I'll wait until he pushes a new version and we will quickly release a new Apktool whenever that happens.


Please no "Apktool doesn't work w/ 4.2" until I push Apktool v1.5.1 PR 2.
 
Last edited:

Top Liked Posts