Gradle & Code Quality

R8 Missing Classes: Fix the Dependency Before Suppressing the Warning

An R8 missing-class error means the optimizer encountered a reference whose definition was not available in the analyzed inputs. Adding -dontwarn can silence a diagnostic, but it does not supply the missing runtime class.

By Updated 2 min read

Capture the complete reference chain

Keep the missing type, the referring class and the affected variant. Read the first meaningful optimizer diagnostic rather than only the final failed-task line.

The Android dependency guide and R8 rules reference are the starting points for deciding whether the problem is resolution, optional code or retention.

Classify the missing dependency

Situation Likely action
Required library omitted Add the correct dependency and scope
Dependency version changed its API Align compatible versions
Compile-only type used at runtime Correct the runtime dependency model
Optional integration never used Confirm the library's documented suppression
Typo or obsolete class reference Fix the source or generated code

A keep rule cannot retain a definition that never entered the build.

Inspect the exact configuration

Use the module and variant that failed:

BASH · REFERENCE EXAMPLE
./gradlew :app:dependencies --configuration releaseRuntimeClasspath

Flavor names change configuration names. Compare compile and runtime graphs when a class compiles successfully but is absent from the packaged dependency set.

Treat generated suggestions as evidence

R8 may produce suggested rules or diagnostics. Read them before applying them. A suppression can be correct for a documented optional platform integration, but a blanket -dontwarn ** masks unrelated future defects.

Avoid downloading arbitrary JARs from untrusted mirrors to satisfy a class name. Verify the artifact publisher and supported version.

Reproduce after the fix

Rebuild the same optimized variant and exercise the code path that references the class. Then check the output dependency inventory. APKLint's Build Analyzer or Gradle Dependency Checker can support configuration review, but neither can resolve a private repository or prove that a missing class is truly optional.

Sources and further reading

  1. Android Developers: Add keep rules
  2. Android Developers: Add build dependencies

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