Can't build APK in Unity after trying to integrate AdMob (IronSource)

1.5k views Asked by At

Integrating the IronSource plugin (v7.0.4.1) doesn't cause any issues. I know this because I am still able to build an APK successfully after installing it. Integrating some of the adapters such as AdColony and UnityAds also do not result in any problems.

However, once I try to integrate the AdMob adapter, I can no longer build an APK. I just get a prompt that says "Android resource linking failed. See the Console for details". Clicking OK results in these error logs:

enter image description here enter image description here enter image description here

3

There are 3 answers

0
Opu On

In my case, the old audience network plugin caused the problem. Build failed when both Audience network and AdMob were present. After removing the audience network plugin (as I am not using it), the build was successful. Update SDK, and other plugins. Resolve, and then try again.

0
Atul Patel On

Tested : Unity 2020.3.11f1 and GoogleMobileAds-v6.1.2

Step 01 : Install GoogleMobileAds plugin and setup and Asset > External Dependency Manager > Android Resolver > resolve.

Step 02 : Set Target API Level 30 in Player Setting.

enter image description here

Step 03 : Tick in Custom Main Gradle Template and Custom Launcher Gradle Template.

enter image description here

Step 04: How mainTemplate and launcherTemplate files generating. [If not view then first build ignore the errors]

enter image description here

Step 05 : Added below code into mainTemplate.gradle file with your favorite editor.

buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        // Must be Android Gradle Plugin 3.6.0 or later. For a list of
        // compatible Gradle versions refer to:
        // https://developer.android.com/studio/releases/gradle-plugin
        classpath 'com.android.tools.build:gradle:3.6.0'
    }
}

allprojects {
   repositories {
      google()
      mavenCentral()
      flatDir {
        dirs 'libs'
      }
   }
}

//Look like that enter image description here

Step 06 : Download Gradle gradle-5.6.4-all.zip from grdale.org. Download from https://services.gradle.org/distributions/

After download extract the file and set gradle path into Edit > Preference > External Tools > Gradle Install with Unity(recommended) UnChecked

enter image description here

Step 07 : Build

Helpful Link : https://developers.google.com/ar/develop/unity-arf/android-11-build

0
Reaver On

Solution

The AdMob SDK requires use of the <queries> tag which for Unity 2018 and higher needs a newer Gradle feature which doesn't come with the Gradle version Unity packages.

Here is another post with the same issue.