June 30, 2021

    Meet Proguard 7.1: Featuring a new Android Gradle Plugin, Java 16 Support and More

    We are proud to announce the release of ProGuard 7.1, the newest version of our open-source optimizer and shrinker. This latest version provides improved usability and incorporates a number of exciting new features, including:

    • AGP 7 Compatible Gradle Plugin
      Ensure continued use of ProGuard, even with the anticipated changes in the upcoming release of Android Gradle Plugin 7
    • Java Support
      Use ProGuard with the latest versions of Java. We now fully support Java up to version 16

    • New Optimizations
      Optimize code even further, and potentially shrink apps even more than before, thanks to five additional code optimizations

    • Availability on Maven Central
      Integrate ProGuard with build systems, like Gradle, much easier since ProGuard is now available on Maven Central

    • Easier Configuration
      Configure ProGuard easier and faster thanks to improved-keeprule suggestions given by-addconfigurationdebugging

    AGP 7 compatible Gradle plugin

    The way ProGuard is integrated into Android projects is changing because AGP 7 will no longer allow developers to disable R8 with the android.enableR8 Gradle property.

    ProGuard 7.1 includes a new Gradle plugin which allows for a seamless integration with this new AGP version. A detailed and step-by-step guide for transitioning from the previous plugin is provided in the upgrading guide.

    • Simple integration with Android Gradle Projects by adding a dependency on the ProGuard Gradle Plugin artifact and applying the com.guardsquare.proguard plugin, as presented in the gradle setup instructions.

    Java support

    New Java versions are released every 6 months. To allow ProGuard to continue to optimize, obfuscate and shrink Java class files we have added support for the latest releases, up to Java 16. This includes:

    • Add support for processing Java 14, 15 and 16 class files.
    • Add support for Java 14 sealed classes.
    • Add support for records (previewed in Java 15/16, targeted for Java 17).

    New optimizations

    ProGuard 7.1 adds five new code optimizations. These optimizations aim at reducing the number of classes required by the application and help pinpoint the specialized type wherever possible. This can have a positive impact on code shrinking and application performances.

    • method/specialization/returntype - specializes the types of method return values, whenever possible.
    • method/specialization/parametertype - specializes the types of method parameters, whenever possible.
    • method/generalization/class - generalizes the classes of method invocations, whenever possible.
    • field/specialization/type - specializes the types of fields, whenever possible.
    • field/generalization/class - generalizes the classes of field accesses, whenever possible.

    Maven central

    ProGuard was previously hosted at JCenter, but this repository has recently been removed. ProGuard is now published to Maven Central.

    • Simple integration: follow the gradle setup instructions to select themavenCentral()repository and dependencies to the proguard-gradle artifact.

    Easier configuration

    The-addconfigurationdebuggingallows configuring ProGuard-keeprules. For more details and to see this in action have a look at Configuring ProGuard, an Easy Step-by-Step Tutorial.

    -addconfigurationdebuggingpreviously reported -keep rule suggestions for classes, methods or fields that did not exist in the app. Such-keeprules are not necessary.

    ProGuard 7.1 improves the suggestion of-keeprules by only suggesting rules for classes, methods and fields that were actually in the original application.

    • More precise-keeprule suggestions provided by -addconfigurationdebugging.
    • Easier ProGuard-keeprules configuration.
    • Reduced ProGuard configuration size.

     

    Download the latest ProGuard 7.1.0 from GitHub or easily integrate it into your Gradle project via Maven Central.

    Guardsquare

    Get tips and advice on your configuration from our team of engineers and skilled community members.

    Join the Guardsquare Community >

    Other posts you might be interested in