[General Questions and Answers] HGStyleOfficial:
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]java.base@20.0.1[/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