Several Android-specific questions, while integrating Ads Mediation (15+ networks)


I’m trying to develop native extension for AppLovin Max ads mediation (WIP Android only - AdColony, AppLovin, Pangle, Facebook, InMobi, Smaato, Tapjoy, Verizon, Vungle only adapters for now)

First, I want to say a “Great thank you” to @AGulev for Unity Ads and new-admob (which I use as template and example - I couldn’t have done anything without them).
And then I describe the problems faced while integrating ad-networks AAR-packages (and that may face anyone who will integrate ads mediation):

:white_check_mark: Java 8 Support (Smaato, Verizon) and element <queries> in <manifest> (AdMob, InMobi, myTarget, Pangle)
Workaroud: Use Defold 1.2.181 BETA (or above) with D8 support

:white_check_mark: Facebook Ads
Got an runtime-error on ads initialization:

Can't load Audience Network Dex. Please, check that audience_network.dex is inside of assets folder. audience_network.dex

Related to #5710
Workaroud: Manually add custom assets to native extension resources. In my case - copy audience-network-sdk-6.3.0.aar/assets/audience_network.dex to myextension/res/android/assets/audience_network.dex.
(also already there is PR - thanks Defold devs for fast fix)

:white_check_mark: 3rd party activity from ARR
Got an runtime-error while opening Mediation Debugger activity:

Caused by: java.lang.ClassNotFoundException: Didn't find class "com.applovin.sdk.R$layout" on path: DexPathList[[zip file "/data/app/com.defold.applovinexample/base.apk"],nativeLibraryDirectories=[/data/app/com.defold.applovinexample/lib/arm, /data/app/com.defold.applovinexample/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib, /data/downloads, /data/priv-downloads]]
    at dalvik.system.BaseDexClassLoader.findClass(

Workaroud: add package name to ext.manifest aaptExtraPackages section to force AAPT2 to generate R.class file in package namespace. ('com.applovin.sdk' in my case).
I’m not sure this is expected behaviour and I didn’t found this in navive extension manuals.

:x: Mintegral (not solved)
Got an runtime-error on ads initialization:

Caused by: java.lang.ClassNotFoundException: Didn't find class "com.mintegral.msdk.out.MTGConfiguration" on path: DexPathList[[zip file "/data/app/com.defold.applovinexample/base.apk"],nativeLibraryDirectories=[/data/app/com.defold.applovinexample/lib/arm, /data/app/com.defold.applovinexample/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib, /data/downloads, /data/priv-downloads]]
    at dalvik.system.BaseDexClassLoader.findClass(

Class com.mintegral.msdk.out.MTGConfiguration is present in classes2.dex (but not in main DEX) - seems related to legacy-multidex problem. Also this error may be related to Fb+Push issue

I tried to set minSdk=21 or change in manifest <application android:name="androidx.multidex.MultiDexApplication"> to avoid legacy-multidex but it didn’t help.

:x: AdMob / Google Ad Manager and Applovin conflict (not solved)
com.applovin:applovin-sdk:10.1.2 and contains conflicting dependencies, got an D8 Compilation failed error:

Error in /tmp/.gradle/unpacked/
Type is defined multiple times: /tmp/.gradle/unpacked/, /tmp/.gradle/unpacked/
Compilation failed

I tried to play around ext.manifest aaptExcludePackages section, but looks like section is obsolete and I’ve got Error in 'extension-maxsdk/ext.manifest': Manifest context variable unsupported: aaptExcludePackages.

:x: myTarget (not solved)
Got an extender-error:

Missing 'package' key attribute on element package at [] 
AndroidManifest Validation failed

Not sure but it may be related to manifest-merger version don’t support Android 11 specific manifests.

And I will be grateful for any clues how to solve problems above…



Note that we just now had to revert the support for d8 in the 1.2.181 BETA because it didn’t work with certain packages (e.g. facebook). (ff5b94e)



Sad to hear this… But in any case, I’m happy with the fact that now we always can to build and run extender locally. And for me it’s a good opportunity to learn Docker at last.

PS I’m not sure (not an android specialist) but seems to run with --release flag D8 multidex behavior similar to DX (place classes in main dex while 64k methods limit not reached), but may affect other unwanted properties (strip debug info etc.)

1 Like


We will reintroduce d8 support in the next release again.

I believe --debug is default for d8. But for it to work the java classes must be compiled (using javac) with the -g option to include the required debug info. D8 arguments: