How do I compile Apktool into a Linux binary ? - General Questions and Answers

Hello, I'm posting that thread because I need help to compile the Apktool JAR file into a Linux binary.
I need to compile it into a binary because my VPS can't run Java, when running Java, there is a lot of problems, maybe that because my portable Java installation is wrong, I dont know.
(my VPS provider dont provide Java and has disabled tools like APT, YUM, PACMAN, SNAP or DPKG...)
I thought it could be a better idea to compile the Apktool JAR file into a native Linux binary, and I've done it, but there is a problem in the binary.
Since my server is on Linux x86_64 (Unknown distribution) and my PC is on Linux x86_64 (MX Linux, Debian-based), it could work.
After a lot of searching, I finally installed GraalVM Native Image and made a command to compile the JAR file into a binary.
And after 15 minutes on my (bad) computer it generated a Linux binary file, but when trying to decompile an APK on my computer with it, it gaves:
$ ./apktool d myapp.apk -f
I: Using Apktool 2.7.0 on myapp.apk
I: Loading resource table...
Exception in thread "main" java.nio.charset.UnsupportedCharsetException: CESU8
at [EMAIL][email protected][/EMAIL]/java.nio.charset.Charset.forName(Charset.java:537)
at brut.androlib.res.decoder.StringBlock.<init>(StringBlock.java:277)
at brut.androlib.res.decoder.StringBlock.read(StringBlock.java:52)
at brut.androlib.res.decoder.ARSCDecoder.readTableHeader(ARSCDecoder.java:79)
at brut.androlib.res.decoder.ARSCDecoder.decode(ARSCDecoder.java:51)
at brut.androlib.res.AndrolibResources.getResPackagesFromApk(AndrolibResources.java:780)
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:74)
at brut.androlib.ApkDecoder.getResTable(ApkDecoder.java:251)
at brut.androlib.ApkDecoder.decode(ApkDecoder.java:109)
at brut.apktool.Main.cmdDecode(Main.java:175)
at brut.apktool.Main.main(Main.java:79)
But if on my computer I run the same command but with the JAR file, it gaves:
$ java -jar apktool.jar d myapp.apk -f
I: Using Apktool 2.7.0 on myapp.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: /home/hg/.local/share/apktool/framework/1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Baksmaling classes.dex...
I: Baksmaling classes2.dex...
I: Copying assets and libs...
I: Copying unknown files...
I: Copying original files...
(so it works on the same APK with the JAR file but not with the binary)
In this message, there will be the binary I've compiled. (for Linux x86_64 only)
Please note that I'm new to XDA Developers, but also to Java and GraalVM Native Image: I never touched one single line of Java code.
I made Python programms, but I never made any Java code. And I discovered GraalVM yesterday.
Can someone help me please ?
And, it is possible that I have problems with APK frameworks when running the binary on my server ?
I can only access to files under my home directory, will I need to install frameworks manually in an "apktool" directory on my home directory ?
Thanks in advance, HGStyleOfficial (my real nickname is HGStyle but it was allready taken on the forum by a random guy registered in 2010 and who didnt had many activities on the forum...)
Apktool version 2.7.0 (latest)
OpenJDK 11.0.18 for Debian
GraalVM 20.0.1 (Java 20, Linux x64)
native-image 20.0.1 2023-04-18

Related

[Resolved] Newsbie question: apktool - recompiled binary is not installable

Hi,
first of all sorry for posting in a new thread, but I'm not allowed to post in apktool-thread (to few postings).
I'm trying to edit permissions of apk's with apktool.
Code:
C:\temp\android\apktool>apktool d -s -f "n:\Cut the Rope - Android\cut-the-rope.apk" test
I: Copying raw classes.dex file...
I: Loading resource table...
I: Loaded.
I: Loading resource table from file: C:\Users\Carsten\apktool\framework\1.apk
I: Loaded.
I: Decoding file-resources...
I: Decoding values*/* XMLs...
I: Done.
I: Copying assets and libs...
No, errors.
I reassemble it unmodified.
Code:
C:\temp\android\apktool>apktool b test test.apk
I: Copying classes.dex file...
I: Checking whether resources has changed...
I: Building resources...
I: Copying libs...
I: Building apk file...
No, errors.
Installing the file
Code:
F:\android-sdk-windows\platform-tools>adb install c:test.apk
2327 KB/s (2931257 bytes in 1.230s)
pkg: /data/local/tmp/c:test.apk
Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES]
gives an error.
Code:
$logcat *:e
/PackageParser( 460): Package com.feelingtouch.physical has no certificates at entry assets/font/Plok.ttf; ignoring!
Any ideas what's wrong?
greetings
Carsten
found the solution. All packages have to be signed, even if they are installed via adb.
Debug test signing is enough:
Code:
jarsigner -verbose -keystore C:\Users\Carsten\.android\debug.keystore -storepass android c:test.apk androiddebugkey

Decompiling Settings.apk on Xperia V - Android 4.3

I'm using android 4.3 stock version of framework-res.apk to decompile Settings.apk but Apktool 1.5.2 & Apktool 2.0 beta are giving me this error :
"Can't find framework resources for package of id: 2. You must install proper framework files, see project website for more info."
any help ?
Found the Problem & fixed apktool
apparently I needed to install SemcGenericUxpRes.apk before decompiling the Settings.apk file, another problem presented itself at this point..
installing SemcGenericUxpRes.apk using apktool 2.0 beta 7 resulted an error :
Exception in thread "main" brut.androlib.AndrolibException: Multiple types: <emp
ty>
at brut.androlib.res.data.ResPackage.addType(ResPackage.java:168)
at brut.androlib.res.decoder.ARSCDecoder.readType(ARSCDecoder.java:131)
at brut.androlib.res.decoder.ARSCDecoder.readPackage(ARSCDecoder.java:10
9)
at brut.androlib.res.decoder.ARSCDecoder.readTable(ARSCDecoder.java:81)
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(AndrolibResource
s.java:686)
at brut.androlib.Androlib.installFramework(Androlib.java:640)
at brut.apktool.Main.cmdInstallFramework(Main.java:249)
at brut.apktool.Main.main(Main.java:91)
so I did some research and fixed the 'Multiple types' bug in apktool (I'll attach the fixed version at the end of the post) ,and now every thing worked just fine ^_^
C:\apk>java -jar apktool-fixed.jar if framework-res.apk
I: Framework installed to: C:\Users\User\apktool\framework\1.apk
C:\apk>java -jar apktool-fixed.jar if SemcGenericUxpRes.apk
I: Framework installed to: C:\Users\User\apktool\framework\2.apk
C:\apk>java -jar apktool-fixed.jar d Settings.apk
I: Using Apktool 2.0.0-Beta7 on Settings.apk
I: Loading resource table...
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: C:\Users\User\apktool\framework\1.apk
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
I: Loading resource table from file: C:\Users\User\apktool\framework\2.apk
Cleaning up unclosed ZipFile for archive C:\Users\User\apktool\framework\2.apk
I: Loading resource table...
Cleaning up unclosed ZipFile for archive C:\Users\User\apktool\framework\1.apk
I: Copying assets and libs...
I: Copying unknown files/dir...
I: Copying original files...
fixed apktool 2.0 beta 7 (remove spaces from the url) : http :// www . mediafire . com /?cnstb97sszm476y
delete as I found the answer, please ignore

[Q&A][LP][5.0.2]Decompile Settings.apk error

Everything works like a charm when I decompile other APKS but when I tried settings.apk it didn't work saying this error.
I have installed everything like deodexed systemui.apk and framework-res.apk.
I dont know weather its with SemcGenericUxpRes or some stuff.
C:\apktool>apktool d settings.apk
I: Using Apktool 2.0.0 on settings.apk
I: Loading resource table...
I: Decoding Shared Library (com.sonyericsson.uxp), pkgId: 2
I: Decoding AndroidManifest.xml with resources...
I: Loading resource table from file: C:\Users\m0rpheus\apktool\framework\1.apk
I: Decoding Shared Library (com.sonyericsson.uxp), pkgId: 2
I: Regular manifest package...
I: Decoding file-resources...
I: Decoding values */* XMLs...
Can't find framework resources for package of id: 2. You must install proper framework files, see project website for more info.
Help anyone!
Its fixed now I installed com.sonyericsson.uxp.apk to framework files and its working now.
Mod please delete this thread
HOW
how can you installer the com.sonyericsson.uxp.apk to framework ?

EMERGENCY, please help with Apk Easy Tool, trying to compile an app but it shows this

07/09/2019 18:20:25
Compiling APK file... (CMD mode: WriteLine)
/c "java -Xmx1024m -jar "C:\Program Files (x86)\APK Easy Tool\Apktool\apktool_2.4.0.jar" b -f -o "C:\Users\madani\Desktop\APK Easy Tool\recompiled\tyblate-recompiled.apk" "C:\Users\madani\Desktop\APK Easy Tool\decompiled\tyblate" "
I: Using Apktool 2.4.0
I: Smaling smali folder into classes.dex...
I: Building resources...
S: WARNING: Could not write to (C:\Users\madani\AppData\Local\apktool\framework), using C:\Users\madani\AppData\Local\Temp\ instead...
S: Please be aware this is a volatile directory and frameworks could go missing, please utilize --frame-path if the default storage directory is unavailable
W: ERROR: 'C:\Users\madani\AppData\Local\Temp\APKTOOL7465868708093004443.tmp' exists (use '-f' to force overwrite)
brut.directory.DirectoryException: java.util.zip.ZipException: zip file is empty
------------------------------------------

Error on compile with apktool

Apktool Version -2.6.1
Operating System -Windows
APK From -ROM android 12
log from apk easy tool:
[all log](https://github.com/iBotPeaches/Apktool/files/8921654/RecentLog-Instance1.txt)
```
I: Using Apktool 2.6.1
I: Checking whether sources has changed...
I: Smaling smali folder into classes.dex...
I: Checking whether sources has changed...
I: Smaling smali_classes2 folder into classes2.dex...
I: Checking whether resources has changed...
I: Building resources...
W: C:\Users\mor\Documents\APK Easy Tool\1-Decompiled APKs\MtkSettings\res\values\attrs.xml:55: error: duplicate symbol '@null'.
```
Frameworks:
framework-res.apk
framework dolder
APK:
https://drive.google.com/file/d/1XA3UTWS91GeF72Gdfj852ZLQIZc5kWkw/view?usp=sharing (settings app)
Thanks.

Categories

Resources