Support of apk files by standalone version

Hi,
Does the standalone version of the ProGuard support “apk” files?
I receive constantly the following error for any apk that I’ve tried:

Reading program apk [./app-release.apk] (filtered)
Unexpected error
java.io.IOException: The input doesn't contain any classes. Did you specify the proper '-injars' options?

Thank you in advance

Hello,
Yes, Proguard supports .apk files as an input. Can you clarify which parameters you provided to Proguard or the command you tried?

Yours

1 Like

Hi,
I used the simplest parameters :

-injars ./app-orig.apk
-outjars ./apk-obfuscated.apk
-libraryjars /home/user/Android/Sdk/platforms/android-34/android.jar

Adding obfuscation rules doesn’t change anything.

It still gives the same output “The input doesn’t contain any classes”.

Hi,
Is that the whole error log you’re seeing ? Can you share the full log?

Hi,
Sure, this is the complete log:

ProGuard, version 7.5.0
Unexpected error
java.io.IOException: The input doesn’t contain any classes. Did you specify the proper ‘-injars’ options?
at proguard.InputReader.execute(InputReader.java:143) ~[proguard.jar:7.5.0]
at proguard.pass.PassRunner.run(PassRunner.java:24) ~[proguard.jar:7.5.0]
at proguard.ProGuard.readInput(ProGuard.java:330) ~[proguard.jar:7.5.0]
at proguard.ProGuard.execute(ProGuard.java:123) ~[proguard.jar:7.5.0]
at proguard.ProGuard.main(ProGuard.java:648) ~[proguard.jar:7.5.0]

I have the same results on Ubuntu 22 and 24.

Hello,
Thank you. As it turns out, the error log itself doesn’t give much information. Could you please share the list of contents of the unzipped initial apk, by running **unzip -l** on the input apk ? Does it contain a classes.dex file ?
Yours.

Hi
Thank you for your help!

But I don’t think it’s an application-related issue as I have the same problem with all application I’ve tried.
And, of course, they contain classes.dex :slightly_smiling_face:

It’s rather a problem of incompatibility with Java or android.jar

This is the Java version that I’m using:

java 22.0.2 2024-07-16
Java™ SE Runtime Environment (build 22.0.2+9-70)
Java HotSpot™ 64-Bit Server VM (build 22.0.2+9-70, mixed mode, sharing)

As a sample I can share the output of ProGuard for the RootBeer demo application ( GitHub - scottyab/rootbeer: Simple to use root checking Android library and sample app ) that produces the same result:

ProGuard, version 7.5.0
Unexpected error
java.io.IOException: The input doesn’t contain any classes. Did you specify the proper ‘-injars’ options?
at proguard.InputReader.execute(InputReader.java:143) ~[proguard.jar:7.5.0]
at proguard.pass.PassRunner.run(PassRunner.java:24) ~[proguard.jar:7.5.0]
at proguard.ProGuard.readInput(ProGuard.java:330) ~[proguard.jar:7.5.0]
at proguard.ProGuard.execute(ProGuard.java:123) ~[proguard.jar:7.5.0]
at proguard.ProGuard.main(ProGuard.java:648) ~[proguard.jar:7.5.0]

Is there any way to get more verbose output than with a “-verbose” flag?

The content of the configuration file:
-injars /home/user/Apps/rootbeer/app/build/outputs/apk/debug/RootBeerSample-0.1.1-[11]-> debug.apk

-outjars ./apk-obfuscated.apk
-libraryjars /home/user/Android/Sdk/platforms/android-34/android.jar

-assumenosideeffects class android.util.Log {
public static boolean isLoggable(java.lang.String, int);
public static int v(…);
public static int i(…);
public static int w(…);
public static int d(…);
public static int e(…);
}

The dex files inside the apk:

unzip -l /home/user/Apps/rootbeer/app/build/outputs/apk/debug/RootBeerSample-0.1.1-[11]-debug.apk | grep dex
1312 1981-01-01 01:01 classes6.dex
9084 1981-01-01 01:01 classes4.dex
15480 1981-01-01 01:01 classes2.dex
26260 1981-01-01 01:01 classes5.dex
490852 1981-01-01 01:01 classes3.dex
9787156 1981-01-01 01:01 classes.dex

Hello,
Sorry, my bad. I checked internally and it seems APK files are in fact not supported by Proguard. ProGuard is only able to process Android applications as part of the Android build pipeline, or by post processing in standalone mode, but then the input needs to be a jar file :
bin/proguard.sh -injars path/to/my-application.jar
-outjars path/to/obfuscated-application.jar
-libraryjars path/to/java/home/lib/rt.jar

This is what I expected :slight_smile:

Thank you