Anh Tran dev notes

Production bugs from mobile and backend work, written up with the fix and how it was checked.

Note 05 / Flutter / Ads / Android

Adding five ad networks to AdMob mediation in Flutter: the Maven repo, the Unity SDK pin and the 28 new activities

A checklist from wiring Liftoff, Meta, Mintegral, AppLovin and Unity adapters into a Flutter app: the repository Gradle cannot find, a Unity SDK that does not match its adapter, SKAdNetwork ids, consent, and the manifest check you need afterwards.

By
Trần Thế Anh, Software Engineer
Published
Work done
October 2026, GirlX (Flutter, Android and iOS)
Stack
Flutter, google_mobile_ads 9.1.0, gma_mediation_* plugins, Gradle Kotlin DSL
Reading
5 min, 1,068 words

Adding a mediation network to AdMob in Flutter looks like one line in pubspec.yaml. Five networks at once turns into a build failure, a SDK version mismatch that Gradle accepts without complaint, a longer iOS plist and 28 new Android activities. This note lists what actually had to change in one app in October 2026, and in what order, so the next app takes an hour instead of an afternoon.

The part that earns money (mediation groups, network keys, app-ads.txt lines) lives in consoles, not in code. Everything below is code and build configuration only.

The packages

The Google-maintained mediation plugins each wrap one network’s adapter. The versions this app ended up with, as written in its pubspec.yaml:

dependencies:
  google_mobile_ads: 9.1.0
  gma_mediation_liftoffmonetize: ^1.5.5
  gma_mediation_meta: ^1.7.1
  gma_mediation_mintegral: ^2.1.5
  gma_mediation_applovin: ^2.6.5
  gma_mediation_unity: ^1.11.1
  gma_mediation_pangle: ^4.2.1

google_mobile_ads is pinned to an exact version rather than a caret range, because the app’s code reads an internal of the plugin (a leased ad view looks up an ad id through the plugin’s instance manager), and a floating version would let that internal move without a build error pointing at it. All the mediation packages of that release required google_mobile_ads ^9.1.0 and Android minSdk 24. Check both before you start: the version constraint is in each plugin’s pubspec.yaml, the minimum SDK in its android/build.gradle.

The Pangle plugin was added after the first five. In Ad Inspector the line “Pangle US SDK” showed a failure because the adapter was simply not in the app. Ad Inspector is the quickest way to see which adapters initialised.

Gradle cannot find the Mintegral SDK

Mintegral’s Android SDK is not on Maven Central or Google’s repository. The plugin pulls it, but Gradle needs the vendor’s repository declared in the project:

// android/build.gradle.kts
allprojects {
    repositories {
        google()
        mavenCentral()
        maven { url = uri("https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea") }
    }
}

Without it the build fails at dependency resolution with an unresolved Mintegral artifact. The fix is the one maven line above.

The Unity adapter and the wrong SDK underneath

This one produces no error. The gma_mediation_unity plugin depends on the adapter com.google.ads.mediation:unity:4.20.1.0, built against Unity Ads 4.20.1. The plugin also pins the Unity SDK itself to unity-ads:4.17.0. The adapter’s POM does not declare a dependency on the SDK, so Gradle has no reason to upgrade it. The result is adapter 4.20.1 running on SDK 4.17.0.

The mismatch is visible in the merged manifest, which still contained AdUnit*Activity entries that only the 4.17 SDK declares. To find it, ask Gradle what it chose:

./gradlew :app:dependencies --configuration releaseRuntimeClasspath | grep -i unity

(The configuration name depends on your build flavors. This app has several, and the full command goes through the project’s heavy-job wrapper.) The fix is one line in the app module, naming the SDK that the adapter was built for:

implementation("com.unity3d.ads:unity-ads:4.20.1")

The rule that came out of it: for each plugin, compare the adapter’s stringVersion in the plugin’s own android/build.gradle (inside the pub cache) with the SDK Gradle really resolved. In this app the other four networks’ adapter POMs pulled the right SDK. Unity was the exception. Whenever you upgrade the plugin, change the pin on the same day. The comment next to the line in the app says exactly that, which is the only reason it survives a refactor.

iOS: the SKAdNetwork list

On iOS each network needs its SKAdNetwork identifiers in Info.plist under SKAdNetworkItems, or its installs cannot be attributed. The list starts from the one Google publishes for AdMob mediation, plus each network’s own id (for example Liftoff, Meta, Mintegral, AppLovin and Unity each have one or two). After de-duplicating, the plist in the commit that added the adapters went from 45 identifiers to 156 (counted in the repository’s git history). Check the file with plutil -lint before building.

Each adapter reads the consent string that Google’s User Messaging Platform wrote (the TCF string and the Additional Consent string). The tempting move is to call a network’s setHasUserConsent(true) yourself to “make sure”. Do not. You would be guessing a legal state. Wire the setters only if the app has its own CCPA opt-out screen, and then pass the user’s real choice.

Twenty-eight new activities

Each network’s SDK adds activities to the merged manifest, 28 across the five (26 classified in the commit plus 2 that are blocked). Those are the objects a pre-launch robot opens with an empty intent (the previous note in this series describes the crash that causes). So the same commit that adds the adapters has to classify the new activities, either “dies with a bare intent, guard it” or “survived am start -n, add to the known-good list”. The merged-manifest gate fails the build until every new activity is classified, which is what makes this a checklist item instead of a memory.

A test that fails when someone removes a plugin

A single Dart test reads pubspec.yaml, the Gradle file and Info.plist and asserts that all five packages are present, the Mintegral repo is declared and each network’s SKAdNetwork id is in the plist. It runs in seconds and catches the usual regression: a later cleanup that “removes unused dependencies”.

Order of work

  1. Add the plugins to pubspec.yaml, right below google_mobile_ads.
  2. Declare the Mintegral repository.
  3. Merge the SKAdNetwork ids and lint the plist.
  4. Resolve the Android dependency tree and compare every adapter with its SDK. Pin Unity.
  5. Run the manifest gate and classify the new activities.
  6. Build Android and iOS release variants. On iOS check that the frameworks folder contains an adapter framework for each network.
  7. Open Ad Inspector on a device and look for each adapter reporting that it initialised.

What is not covered, and what was not re-run

Code in place does not mean mediation is live. The mediation groups in the AdMob console, the network keys and the app-ads.txt entries have to be added separately and cover every ad unit, so report “adapters installed, sources not enabled” until that is done. I read the app’s pubspec.yaml, Gradle files and checklist while writing this note. I did not rebuild the app. The 45 and 156 identifier counts were checked against the repository’s git history and current Info.plist; “28 activities” is the count recorded in the commit that classified them (26 classified plus 2 blocked).