Gradle & Code Quality

ProGuard for Java vs R8 for Android: Choose the Correct Pipeline

ProGuard is a Java bytecode shrinker, optimizer and obfuscator. For a modern Android application, R8 is normally the AGP-integrated optimizer; installing standalone ProGuard is not the default way to enable Android release shrinking.

By Updated 2 min read

Start with the output platform

The ProGuard manual describes its Java-oriented processing pipeline. Android projects should start from the R8 integration guide.

A shared Java library may be processed differently depending on whether it is distributed as a library or incorporated into an Android app. Do not run multiple transformation stages without understanding how mappings and public APIs survive.

Identify input and library code

Application input is transformed. Library code supplies types and relationships needed for analysis but is not simply interchangeable with the program input.

Missing platform or dependency classes can generate warnings. Suppressing all warnings hides analysis gaps; determine whether a dependency is genuinely optional, incorrectly supplied or absent from the runtime.

Keep public contracts deliberately

For a reusable library, public API names, reflective access and serialization contracts can matter to downstream consumers. An application can often optimize more aggressively because it controls the whole program.

Distribution Review focus
Standalone Java application Entry points and runtime dependencies
Published Java library Public API and consumer compatibility
Android app through AGP R8 configuration and Android runtime testing
Library consumed by Android apps Appropriate consumer rules

Configuration syntax overlap does not guarantee identical support for every option or processing assumption.

Preserve useful diagnostics

Archive the mapping associated with the exact transformed output. Rebuilding later from apparently identical source may not reproduce the same mapping if dependencies or tooling changed.

Test reflection and serialization with the processed artifact, not just unprocessed unit-test classes. Keep a minimal reproducer for any rule added to solve a compatibility failure.

Apply APKLint at the right stage

APKLint's obfuscation checker is useful for examining an Android package after the build. It is not a replacement for running ProGuard on Java inputs and cannot validate a standalone Java distribution. Choose the build pipeline first, then use artifact inspection to check the result it actually produced.

Sources and further reading

  1. Android Developers: Enable optimization with R8
  2. Android Developers: Add keep rules
  3. ProGuard manual — Guardsquare

Reference review: 22 September 2026. Examples illustrate the workflow; check your installed versions, release artifact and account-specific Console requirements before applying them. This guide is not a claim that APKLint executed your project or verified your private account.

APKLint

Android inspection tools and practical release guides. About APKLint · Report a correction