Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does ProGuard support Java 11?

Tags:

java

proguard

I was trying to use Proguard (6.1.0beta1) but got

(Unsupported version number [55.0] (maximum 54.0, Java 10)))

Are there alternatives to ProGuard which can manage with Java 11?

like image 923
tomasz-mer Avatar asked Nov 26 '18 09:11

tomasz-mer


People also ask

What is ProGuard in Java?

ProGuard is a command-line tool that reduces app size by shrinking bytecode and obfuscates the names of classes, fields and methods. It's an ideal fit for developers working with Java or Kotlin who are primarily interested in an Android optimizer.

Is R8 better than ProGuard?

R8 differs from proguard in the following ways: R8 has higher Kotlin language support as compared to proguard. Proguard is mainly used by applications developed using Java. Usually, the R8 compiler is much faster than the proguard compiler.

What is ProGuard and R8 in Android?

R8 configuration files. R8 uses ProGuard rules files to modify its default behavior and better understand your app's structure, such as the classes that serve as entry points into your app's code.


2 Answers

As a follow-up for Karol Dowbecki's answer: ProGuard 6.1.0 beta2 (or newer) supports Java 10, 11 and 12. See #188 Support Java 11


Notice that you'll need to change the libaryjars for Java 9 or newer due to the introduction of the module system. Here's the section of my Gradle Kotlin build script:

if (JavaVersion.current().isJava9Compatible) {
    libraryjars(System.getProperty("java.home") + "/jmods")
} else {
    libraryjars(System.getProperty("java.home") + "/lib/rt.jar")
}
like image 88
simon04 Avatar answered Sep 29 '22 05:09

simon04


Java 11 have introduced changes to the bytecode and class file format:

  • JEP 181: Nest-Based Access Control
  • JEP 309: Dynamic Class-File Constants

Because of above it's unlikely that you will find a working code obfuscator at the moment. Hopefully ProGuard will be updated soon (see #188 Support Java 11 planned for ProGuard 6.1).

like image 27
Karol Dowbecki Avatar answered Sep 29 '22 04:09

Karol Dowbecki