Troubleshooting integrations

This troubleshooting article provides solutions for various, common use cases and problems you may encounter as you install and integrate the Mediation SDK for your made-with-Unity, Android, or iOS app.

Note: To get an idea of how your game could be set up with mediation, refer to the setup code in this sample game source code.

Android

Android Java exception at runtime

If ads are not showing on a new build and you encounter this exception in your runtime device logs:

AndroidJavaException: java.lang.NoSuchMethodError: no static method with name=’initialize’

The SDK and adapter dependencies have resolved to versions that are not supported by the current Mediation package. To resolve this exception:

  1. In the Unity Editor, open your project and go to Project Settings > Player > Publish Settings > Custom Main Gradle Template and ensure the Custom Main Gradle Template checkbox is enabled.
  2. Then, go to the Project tab and navigate to Assets > PlayServicesResolver > Android Resolver > Force Resolve.

Now Gradle should fetch dependencies that are suitable for your current package.

Multidex issue with Android 4.x builds

If you’re having multidex issues for your Android builds, configure and enable your app for multidex. Multidex errors will occur if the minSdkVersion that your app supports is set to below API 21 (Android 5.0).

To resolve multidex errors in your project, open your project in the Unity Editor and go to Project Settings > Player > Publish settings and enable the Custom Launcher Manifest and Custom Launcher Gradle Template.

Open your Custom Launcher Manifest (located in Assets/plugins/Android) and navigate to the application tag and add the following:

android:name="androidx.multidex.MultiDexApplication"

Your Application tag should look like this:

<application android:label="@string/app_name"
android:icon="@mipmap/app_icon"
android:name="androidx.multidex.MultiDexApplication"/>

Then, open your Custom Launcher Gradle Template (located in Assets/plugins/Android) and navigate to the dependencies section (not the buildscript dependencies) and add:

implementation "androidx.multidex:multidex:2.0.1"

Your dependencies section should look like this:

dependencies {
implementation project(':unityLibrary')
implementation "androidx.multidex:multidex:2.0.1"

Finally, in the Android.defaultconfig section of the gradle template file, add:

multiDexEnabled true

Your defaultconfig section should look like this:

defaultConfig {
multiDexEnabled true
minSdkVersion **MINSDKVERSION**
targetSdkVersion **TARGETSDKVERSION**
applicationId '**APPLICATIONID**'
ndk {
abiFilters **ABIFILTERS**
versionCode **VERSIONCODE**
versionName '**VERSIONNAME**'

After updating these files, your application is now supported as a multidex application. If the issue persists, also delete the Temp folder inside your Android project.

Android game build fail due to dex or dependencies

If you’re having issues building your project in the Unity Editor for Android, first ensure that your Android SDK minimum version is set to 5.0 and build again.

If the Android build continues to fail, the issue is likely that there are some conflicting dependencies in your game. For example, if you’re using an SDK version with a dependency that is incompatible with Unity Mediation.

In this case, try updating the version of the other SDK config file before building again. If the Android build fails persist, contact Unity Support or the Open Mediation SDK team for help.

Android resource linking failed

The following error typically happens in Unity 2019 and indicates that your gradle version does not support AndroidX:

/Temp/gradleOut/launcher/build/intermediates/merged_manifests/release/AndroidManifest.xml:38: AAPT: error: unexpected element <queries> found in <manifest>.

This error stems from the AdMob SDK. If you’re not using AdMob as an ad source for Mediation, uncheck the AdMob adapter in the Adapter Configuration settings page of the Unity Editor.

A similar error can occur that requires the same fix:

Error: Missing 'package' key attribute on element package at

See AdMob’s guide on Unity gradle support to upgrade your project’s version of gradle to meet the requirements for AdMob. It is recommend to use the gradle version (5.6.4) specified by the guide above.

After following the steps according to AdMob’s guide, you might encounter this error:

This project uses AndroidX dependencies, but the ‘android.useAndroidX’ property is not enabled.

To resolve this error:

  • In the Unity Editor, go to Project Settings > Player > Publishing Settings and select the Custom Gradle Properties Template checkbox.
  • Navigate to the path below the checkbox and add these two lines to the end of the file:

    android.useAndroidX=true

    android.enableJetifier=true

Another solution to this is to go to the Editor folder in your project, create a file called "AndroidManifestPostGenerateGradleProject.cs" and paste the following script into it:

Copy
class AndroidManifestPostGenerateGradleProject: IPostGenerateGradleAndroidProject {
    public void OnPostGenerateGradleAndroidProject(string path) {
        Debug.Log("Build path : " + path);
        string gradlePropertiesFile = path + "/../gradle.properties";
        if (File.Exists(gradlePropertiesFile)) {
            File.Delete(gradlePropertiesFile);
        }
        StreamWriter writer = File.CreateText(gradlePropertiesFile);
        //writer.WriteLine("org.gradle.jvmargs=-Xmx4096M");
        writer.WriteLine("android.useAndroidX=true");
        writer.WriteLine("android.enableJetifier=true");
        writer.Flush();
        writer.Close();
    }
}

Android Resolution not working with mainTemplate.gradle file

Sometimes, although the MediationAdaptersDependencies.xml is populated, the mainTemplate.gradle file’s dependency section may still be empty even after resolution or forcing resolution:

dependencies {
   implementation fileTree(dir: 'libs', include: ['*.jar'])
   // Android Resolver Dependencies Start
   // Android Resolver Dependencies End
   **DEPS**
}

This Play Services Resolver issue can occur if the Custom Main Manifest is currently added. To resolve this issue with the Custom Main Manifest, remove it, resolve it, then add it back.

 Unity 2019 and Gradle versions above 7.0

In Unity Editor 2019, when upgrading the Gradle version to 7.0+ the following errors may occur:

Execution failed for task ':unityLibrary:compileReleaseJavaWithJavac'.
> Failed to calculate the value of task 
':unityLibrary:compileReleaseJavaWithJavac' property 
'options.generatedSourceOutputDirectory'.
> Querying the mapped value of map(java.io.File 
property(org.gradle.api.file.Directory, 
property(org.gradle.api.file.Directory, fixed(class 
org.gradle.api.internal.file.DefaultFilePropertyFactory$FixedDirectory,

To resolve this error, it’s recommended to downgrade your Gradle version to 6.7 or 6.8.

Gradle File using old aaptOptions noCompress property

If this error occurs in your project console:

UnityException: Error mainTemplate.gradle file is using the old aaptOptions noCompress property definition which does not include types defined by unityStreamingAssets constant.

Resolve this error by updating the aaptOptions section of your mainTemplate.gradle file and update it to the structure shown in this example:

Copy
aaptOptions {
   noCompress = ['.ress', '.resource', '.obb'] + 
unityStreamingAssets.tokenize(', ')
   ignoreAssetsPattern = 
"!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
}**PACKAGING_OPTIONS**

iOS

Xcode error when installing third-party adapters

For your iOS project if you notice that you are able to build successfully with only the Unity Ads adapter, but get the following build error when you try to install any of the other supported third-party adapters in Unity Mediation (for example, AdColony, AdMob, IronSource, etc.):

Undefined symbol: _OBJC_CLASS_$_SKAdImpression

You are getting this error because the selected third party adapter may have a strict requirement to be compatible with a specific version of your Xcode IDE.

To resolve this issue:

  • Ensure you are using Xcode version 13 or higher

  • If you are unable to use Xcode version 13 or higher (because of other system incompatibilities) create a Dependency Override XML file, name it OverrideDependencies.xml, and include it in your project’s Assets/Editor folder. Then, build your iOS project again. Note: The lowest version of Xcode that can be used with the latest version of Unity Mediation is 12.5.1.

The XML file should resemble this format:

Copy
<dependencies>
   <androidPackages>
      <androidPackage spec="adapterName:version"/>  
   </androidPackages>
   <iosPods>
      <iosPod name="adapterName" version="x.x.x">
   </iosPods>
</dependencies>

For example, if you are trying to install AdColony version 4.6.0, your OverrideDependencies file will look like this:

Copy
<dependencies>
   <iosPods>
      <iosPod name="AdColony" version="4.6.0">
   </iosPods>
</dependencies>

The project builds successfully for iOS, but not building in Xcode

For iOS we use CocoaPods for dependencies. When an iOS project is built, go to the build directory and open the .xcworkspace file and not the .xcodeproj file. This will allow your game to build on a device or emulator device.

Errors related to Google Play Services Resolver appear

Assembly 'Assets/ExternalDependencyManager/Editor/Google.IOSResolver_v1.2.166.dll' will not be loaded due to errors:
Assembly name 'Google.IOSResolver' does not match file name 'Google.IOSResolver_v1.2.166'

These errors occur if you are using a different google play services version package from the one provided with the mediation package. Unity editor expects a dll to have the same name as it’s assembly, but it is not the case with these packages. While we recommend using the package included with mediation, you can patch this issue by renaming the dll mentioned, removing the version from its name. In the example above, Google.IOSResolver_v1.2.166.dll should be renamed to Google.IOSResolver.dll.

Requires Higher CocoaPods Version

When building for the iOS platform, if you encounter this issue:

[!] `GoogleAppMeasurement` requires CocoaPods version `>= 1.10.2`, which is not satisfied by your current version, `1.10.0`.

This is referring to the cocoaPods version Play Services Resolver is using. Go to Assets > PlayServicesResolver > iOS Resolver > Install Cocoapods, a popup will appear explaining from which cocoapods location Play Services Resolver is using. Make sure you successfully update the version of that cocoapod executable, and this issue should be resolved.

Ad networks and adapters

Dependency issues with ad networks due to incompatible adapter versions

If you’re having dependency issues with your ad network adapters, verify which version adapter you’re using for your ad networks.

See the minimum recommended ad network Adapters for Android.

See the minimum recommended ad network Adapters for iOS.

The project builds successfully, but crashes on start in a device

If you have AdMob set up as an ad network and your project builds normally but crashes on start in a device, this can happen due to the AdMob adapter settings in your project. In that case, in your project, go to Edit > Project Settings > Services > Mediation, and check if the AdMob app IDs are set properly. Refer to the Configuring ad sources article for more information.

If you don’t receive any fill from any of the ad networks or if you are not able to load any ads

This could happen due to multiple reasons. Verify and confirm the following:

  • Your ad unit, ad network, mediation group and line items are enabled.
  • The appropriate ad network adapters are installed.
  • Your mediation group geo targeting makes sense (for example, if you targeted the US and sent the request from Canada, geo targeting will not work).
  • Your mediation line item has the correct mapping of ad network placements. Make sure the Placement ID is correct.
  • The ad network placements don’t have a very high floor or a filtering/blocking rule.
  • Your Ad Unit ID is correct in the game code. Even an extra space or character in game source code will result in an invalid request.
  • If you still encounter issues with using the Mediation SDK or the Unity Mediation platform, contact Customer Support or the Unity Open Mediation team.

Mediation SDK

Build error due to multiple Unity Ads versions

Unity Mediation pulls compatible Unity Ads SDK versions as a dependency. To resolve the build error, if your game was using Unity Ads or another mediation platform, remove them and reference the Dependency issues with ad networks due to incompatible adapter versions .

Unresponsive Mediation Adapter Configuration screen when installing/uninstalling adapters

In the Unity Editor menu, if you go to Edit > Project Settings > Services > Mediation or Services > Mediation > Configure to open the Mediation Adapter Configuration to attempt to install or uninstall an adapter, the UI may become unresponsive. This is potentially due to a corrupt file (which can occur when upgrading from 0.1 to 0.2). To fix this, delete the file Assets/Editor/MediationAdapterDependencies.xml and try to build. Afterwards, go back to the Adapter Configuration screen and you should be able to install/uninstall again.

Conflict using Unity Ads alongside Unity Mediation

Note: This issue mainly affects the Android native platform and the iOS native platform. The Unity Package platform is evaluating this issue.

You will encounter a conflict if you have Unity Ads installed in your project with the aim to integrate it with Unity Mediation, for example, to use banners from Unity Ads with Unity Mediation, or to use Unity Ads as an ad source for A/B testing performance to compare performance in different mediation providers.

Having Unity Ads as a dependency won’t necessarily break your Unity Mediation integration. However, running Unity Ads initialization code separately alongside Unity Mediation in the same session will cause runtime issues for Unity Ads inside of Unity Mediation. As a result, you will then not be able to load or show Unity Ads in both Unity Mediation and Unity Ads for that session.

The recommended solution is to remove Unity Ads from your game if you wish to use Unity Mediation.

No Linked Project in the Unity Editor

If you see the following errors in your project:

GameID not found
Warning, failed to retrieve GameID from Dashboard

This means that the Editor was not able to fetch your Game ID. The most common reason for this error is due to your Unity Dashboard project not being linked to the project inside the Editor.

To resolve this issue, in the Unity Editor go to Edit > Project Settings > Services to check the status of your linked project. Once your project is successfully linked, try building again.

Error: Ambiguous Match Found for Non-Mediation Play Services Resolver (EDM4U) in use

In the Unity Editor, if you see a similar Exception being thrown in the console:

AmbiguousMatchException: Ambiguous match found.
System.RuntimeType.GetMethodImplCommon (System.String name, System.Int32 genericParameterCount, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Reflection.CallingConventions callConv, System.Type[] types, System.Reflection.ParameterModifier[] modifiers) (at <316d36b1472c4d88ab1721a02433c966>:0)
System.RuntimeType.GetMethodImpl (System.String name, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Reflection.CallingConventions callConv, System.Type[] types, System.Reflection.ParameterModifier[] modifiers) (at <316d36b1472c4d88ab1721a02433c966>:0)
System.Type.GetMethod (System.String name, System.Reflection.BindingFlags bindingAttr) (at <316d36b1472c4d88ab1721a02433c966>:0)
System.Type.GetMethod (System.String name) (at <316d36b1472c4d88ab1721a02433c966>:0)
GooglePlayServices.UnityCompat.GetUnity56AndAboveApplicationIdentifier (UnityEditor.BuildTarget buildTarget) (at /Users/smiles/dev/src/unity-jar-resolver/source/PlayServicesResolver/src/UnityCompat.cs:357)

This error can occur if you are using a newer version of the Unity Editor (2021.2, 2022+) and you are using either:

  • A version of PlayServicesResolver that was provided in an older version of Mediation (0.1.1 and below)
  • A version of PlayServicesResolver provided outside of Mediation

Follow these steps to resolve this error:

  1. Upgrade to the Unity Mediation SDK 0.2.0 or above, then close your project.
  2. Delete the Assets/PlayServicesResolver folder in your project.
  3. Reopen your project, and you should see a prompt to install PlayServicesResolver (a version provided with the Mediation package). Install this version of the PlayServicesResolver.