Skip to main content

Solving "Adapter Not Found" & ClassDefErrors in AdMob Mediation with Vungle

 There are few moments in mobile development more frustrating than successfully compiling a build, only to have the AdMob Mediation Test Suite declare "Adapter Not Found" for a high-value network like Vungle (Liftoff). Even worse is a production crash featuring a NoClassDefFoundError pointing to VungleAdapter or com.vungle.warren.

These errors directly impact revenue by breaking the mediation waterfall. If AdMob cannot instantiate the Vungle adapter, it skips the network entirely, effectively setting your Vungle eCPM to zero.

This guide provides the technical root cause analysis and the specific configuration fixes required to resolve these instantiation errors on Android and iOS.

The Root Cause: Reflection vs. Optimization

To understand why the adapter vanishes, you must understand how AdMob Mediation works under the hood.

The Google Mobile Ads (GMA) SDK does not have a compile-time dependency on the Vungle SDK. Instead, it uses Java Reflection (on Android) or NSClassFromString (on iOS) to dynamically load the adapter class at runtime based on the configuration downloaded from the AdMob servers.

The Android Conflict

Modern Android build toolchains use R8 (the successor to ProGuard) to shrink, obfuscate, and optimize code. R8 analyzes your code entry points and removes any class or method that does not appear to be reachable.

Since the AdMob SDK calls the Vungle Adapter via reflection (e.g., Class.forName("com.google.ads.mediation.vungle.VungleAdapter")), R8's static analysis fails to see a direct link to the adapter. Consequently, R8 strips the adapter class out of the final .dex file. When the app runs, AdMob tries to load the class, fails, and throws a ClassNotFoundException or NoClassDefFoundError.

The iOS Conflict

On iOS, the issue is often related to the Static Linker. If the Vungle adapter is distributed as a static library containing Objective-C Categories, the linker may not include object files that only export categories if they aren't explicitly referenced in the app binary.

Solution: Android (Gradle & R8/ProGuard)

To fix this on Android, you must ensure two things: valid transitive dependencies and strict R8 keep rules.

1. Enforcing Transitive Dependencies

The AdMob adapter artifact declares the specific Vungle SDK version it was built against. However, Gradle resolution strategies can sometimes override this, leading to binary incompatibility.

Explicitly declare both the adapter and the underlying SDK in your app-level build.gradle.kts (Kotlin DSL) or build.gradle.

// build.gradle.kts (App Level)

dependencies {
    // 1. The AdMob SDK
    implementation("com.google.android.gms:play-services-ads:23.0.0")

    // 2. The Vungle (Liftoff) Adapter
    // This artifact usually pulls in the Vungle SDK transitively
    implementation("com.google.ads.mediation:vungle:7.3.0.0")

    // 3. (Optional but Recommended) Explicitly force the Vungle SDK version
    // ONLY do this if you are sure the adapter supports this SDK version.
    // This prevents Gradle from resolving to an older, cached version.
    implementation("com.vungle:publisher-sdk-android:7.3.0")
}

2. The R8/ProGuard Rules (The Critical Fix)

This is the most common point of failure. You must explicitly tell R8 to preserve the adapter classes and the Vungle SDK interfaces, preventing them from being stripped or obfuscated.

Add the following to your proguard-rules.pro file:

# proguard-rules.pro

# 1. Keep the Google Mediation Adapter for Vungle
# This is the class AdMob looks for via Reflection.
-keep class com.google.ads.mediation.vungle.** { *; }

# 2. Keep the Vungle SDK Public API
# If these are obfuscated, the Adapter cannot call them.
-keep class com.vungle.warren.** { *; }
-keep class com.vungle.ads.** { *; }

# 3. specific for Vungle/Liftoff Native Ads (if used)
-dontwarn com.vungle.warren.error.VungleError$ErrorCode

# 4. Essential for Mediation Test Suite detection
-keepattributes SourceFile,LineNumberTable
-keepattributes *Annotation*

Note: Vungle has transitioned packages from com.vungle.warren to com.vungle.ads in newer SDK versions. Keeping both ensures coverage regardless of the adapter version you are using.

Solution: iOS (CocoaPods & Linker Flags)

On iOS, "Adapter Not Found" usually stems from the linker stripping the symbols.

1. Correct Podfile Configuration

Ensure you are pulling the mediation adapter, not just the Vungle SDK. The mediation pod includes the Vungle SDK as a dependency.

# Podfile

platform :ios, '13.0'

target 'MyApp' do
  use_frameworks!

  # AdMob Core
  pod 'Google-Mobile-Ads-SDK'

  # The Mediation Adapter
  # This automatically installs VungleAds SDK
  pod 'GoogleMobileAdsMediationVungle'
end

2. The -ObjC Linker Flag

This is the "silver bullet" for iOS mediation issues. You must force the linker to load all Objective-C classes and categories in the static library.

  1. Open your project in Xcode.
  2. Navigate to Build Settings for your Target.
  3. Search for Other Linker Flags.
  4. Add the flag: -ObjC

If this flag is missing, the categories that the adapter uses to extend the AdMob functionality will not be loaded, resulting in runtime errors or the adapter simply not initializing.

3. SKAdNetwork Configuration

While not strictly an "Adapter Not Found" error, failing to register Vungle's SKAdNetworkIdentifier will result in zero revenue on iOS 14+.

Add this to your Info.plist:

<key>SKAdNetworkItems</key>
<array>
    <!-- Vungle / Liftoff -->
    <dict>
        <key>SKAdNetworkIdentifier</key>
        <string>gta9kk8aea.skadnetwork</string>
    </dict>
    <!-- Google -->
    <dict>
        <key>SKAdNetworkIdentifier</key>
        <string>cstr6suwn9.skadnetwork</string>
    </dict>
</array>

Deep Dive: Managing Version Mismatches

A frequent edge case occurs when the GoogleMobileAdsMediationVungle adapter is updated more slowly than the Vungle SDK itself.

For example:

  • Adapter 7.1.0.0 is built against Vungle SDK 7.1.0.
  • You manually force Vungle SDK 7.3.0 in your Gradle/Podfile.

If Vungle SDK 7.3.0 deprecated or renamed a method that Adapter 7.1.0.0 relies on, you will get a NoSuchMethodError at runtime.

The Fix: Always verify the "Version Compatibility" matrix provided by Google.

Do not upgrade the core network SDK (Vungle) until a compatible AdMob adapter is released, unless you are willing to fork the adapter and fix the breaking changes manually.

Verifying the Fix

Do not rely on production data to verify fixes. Use the Mediation Test Suite.

Android Implementation

// Launching the Test Suite
import com.google.android.ads.mediationtestsuite.MediationTestSuite

// Inside your Activity
MediationTestSuite.launch(this)

iOS Implementation

import GoogleMobileAdsMediationTestSuite

// Inside your ViewController
GoogleMobileAdsMediationTestSuite.present(on: self, delegate: nil)

Success State: When you open the Vungle detail page in the Test Suite:

  1. SDK Status: Should say "Detected" with the correct version number.
  2. Adapter Status: Should say "Detected" (Not "Missing").
  3. Ad Load: Clicking "Load Ad" should successfully render a test video.

Conclusion

The "Adapter Not Found" error is rarely a bug in the SDK itself; it is almost always a build configuration issue involving R8 stripping (Android) or Linker settings (iOS). By enforcing strict ProGuard rules and verifying transitive dependencies, you ensure the reflection mechanisms used by AdMob can locate and initialize the Vungle network, restoring your ad revenue flow.