Gradle build failed after importing GoogleMobileAdsFacebookMediation

Hello all,

Sorry if I have a noob question but I can’t make my game working when I want to add the Google Mobile Ads mediation plugin for Facebook.

I already have the Admob integrated into the game and all works fine, and I want to use Mediation from Admob. I did steps 1 & 2 from Meta Audience Network'ü teklifli sistemle entegre etme  |  Unity  |  Google for Developers, and at step 3, I imported the Google Mobile Ads mediation plugin for Facebook & I did Android Resolver > Force Resolve, but when I want to Build the game I get errors. I tried with the last 3 versions of Google Mobile Ads mediation plugin and still not working. If I delete the FacebookMediationDependencies file (the one generated when plugin is imported), it works fine again.

Any suggestion what I’m doing wrong?

Thank you in advance!!

Hi, I think I faced same problem and here is my solution at this thread.

https://forum.unity.com/threads/solved-gradle-is-not-building-after-importing-facebook-sdk-with-admob-mediation.1102282/

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.

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

7675699--959077--G02.PNG

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

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:
// Android Gradle plugin 8.5 release notes  |  Android Studio  |  Android Developers
classpath ‘com.android.tools.build:gradle:3.6.0’
}
}

allprojects {
repositories {
google()
mavenCentral()
flatDir {
dirs ‘libs’
}
}
}

//Look like that

Step 06 : Download Gradle gradle-5.6.4-all.zip from grdale.org. Download from Gradle Distributions

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

Step 07 : Build

Helpful Link : إنشاء إصدارات متوافقة مع Android 11 باستخدام Unity  |  ARCore  |  Google for Developers

1 Like

After doing this steps It will fail to resolve android dependencies when I click force resolve
Is there a new way to fix this problem ?