androidadmob

Error: "Missing classes detected while running R8." with AdMob 23.4.0


After upgrading AdMob from 23.3.0 to 23.4.0 I get the following errors during Release build:

Missing classes detected while running R8. Please add the missing classes or apply additional keep rules that are generated in [My project folder]/build/outputs/mapping/release/missing_rules.txt.

And

Missing class android.media.LoudnessCodecController$OnLoudnessCodecUpdateListener (referenced from: void com.google.android.gms.internal.ads.zzsp.zzd(int) and 1 other context)
Missing class android.media.LoudnessCodecController (referenced from: android.media.LoudnessCodecController com.google.android.gms.internal.ads.zzsp.zzb and 4 other contexts)

The following issue was reported to Google: https://groups.google.com/g/google-admob-ads-sdk/c/NXPiDjbT2QE/m/PKKmI-38AwAJ

Any workaround except downgrading to AdMob 23.3.0?

How to reproduce the issue in a new, clean project:

  1. Create a new Android project (all default settings).
  2. In the build.gradle.kts of the app module:
    1. Section: android => buildTypes => release, set isMinifyEnabled = true.
    2. Section: dependencies, add api("com.google.firebase:firebase-ads:23.4.0")
  3. Set the build type in the Build Variants to Release.
  4. From the main menu - Build => Build App Bundle(s)/APK(s) => Build Bundle(s).

The build will fail with the same error.

Update: Upgrading to AdMob 23.5.0 cause the same issue.


Solution

  • AdMob 23.4.0 uses android.media.LoudnessCodecController which was added to Android only in SDK 35.

    The documentation of AdMob 23.1.0 clearly states: Requires a minimum compileSdkVersion of 34, however version 23.4.0 is missing the following: Requires a minimum compileSdkVersion of 35.

    There are 3 solutions:

    1. Update compileSdkVersion to 35.
    2. Continue using AdMob 23.3.0 until the project is ready for Android SDK 35.
    3. Use @Miroslav solution to add rules to ProGuard. It's probably safe since those classes were added only in Android SDK 35.