Skip to content
Latchkey

Android R8 "Program type already present" / "Missing class" in CI

R8 runs during minifyReleaseWithR8 to shrink and obfuscate the release build. It fails when two artifacts provide the same class ("Program type already present") or when a referenced class is absent and no rule keeps it ("Missing class").

What this error means

The release build fails in minifyReleaseWithR8 with "Type X is defined multiple times" / "Program type already present: X" or "Missing class X (referenced from: ...)".

Android
> Execution failed for task ':app:minifyReleaseWithR8'.
  > com.android.tools.r8.CompilationFailedException: Compilation failed to complete
  > Program type already present: com.example.util.Strings

Common causes

A duplicate class from two dependencies

Two artifacts (often an old support library and its AndroidX equivalent) define the same class, so R8 sees it twice.

A referenced class missing without a keep rule

Code references a class that is not on the runtime classpath and no ProGuard/R8 keep rule retains or ignores it.

How to fix it

Remove the duplicate dependency

  1. Run the dependency report to find which artifacts provide the duplicate class.
  2. Exclude the obsolete one (for example a legacy support library).
  3. Re-run the release build.
Terminal
./gradlew :app:dependencies --configuration releaseRuntimeClasspath

Add a keep or dontwarn rule for a missing class

For a benign missing reference, keep the class or suppress the warning in the R8 rules file.

app/proguard-rules.pro
-dontwarn com.example.optional.**
-keep class com.example.util.Strings { *; }

How to prevent it

  • Avoid mixing legacy support and AndroidX artifacts.
  • Resolve duplicate classes by excluding the obsolete dependency.
  • Keep R8 rules current for optional or reflective references.

Frequently asked questions

What causes ""Program type already present""?
Two artifacts (often an old support library and its AndroidX equivalent) define the same class, so R8 sees it twice.
How do I fix "Program type already present"?
Remove the duplicate dependency

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card