Search Unity

Gradle build failed after importing GoogleMobileAdsFacebookMediation

Discussion in 'Unity Ads & User Acquisition' started by MariusAAnghel00, Jun 8, 2021.

  1. MariusAAnghel00

    MariusAAnghel00

    Joined:
    Jan 18, 2021
    Posts:
    8
    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 https://developers.google.com/admob/unity/mediation/facebook, 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!!
     
    Last edited: Jun 8, 2021
  2. WaqasGameDev

    WaqasGameDev

    Joined:
    Apr 17, 2020
    Posts:
    118
  3. atulvi

    atulvi

    Joined:
    Oct 28, 2020
    Posts:
    35
    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.

    G01.PNG


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

    G02.PNG

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

    G03.PNG

    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 G04.PNG

    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

    G05.PNG

    Step 07 : Build

    Helpful Link : https://developers.google.com/ar/develop/unity-arf/android-11-build
     
    AvKov likes this.
  4. Mohanad_GX

    Mohanad_GX

    Joined:
    Mar 10, 2020
    Posts:
    13
    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 ?