【Unity】Connect to MAX aggregated advertising SDK Applovin + GoogleAdmob

Version:
Unity: 2019.4.35f1
gradle plugin: 4.2.0 (actually 7.0+ corresponding to build_tools:34.0.0)
ndk: android-ndk-r19build_tools: 34.0 .0
jdk: 1.8.0_241 gradle: 6.7.1 (actually 7.0+ corresponds to build_tools:34.0.0)

Documentation:
6.0.1(Android 12.0.0 & iOS 12.0.0) MAX aggregated advertising Unity:MAX Mediation Documentation a>

8.5.3 Google Admob:Releases · googleads/googleads-mobile-unity · GitHub 

To deal with the error message 34.0.0 is corrupted that may be caused by incorrect versions of gradle and build_tools:
Android Installed Build Tools revision 34.0.0 is corrupted. Remove and install again using the SDK -CSDN Blog

 (That is, modify the naming of d8.bat in the build_tools directory and d8.jar in build_tools/lib to dx, and the suffix remains unchanged.)

Normally, the corresponding gradle version should be found and the correct gradle plugin version should be set.

升级 Gradle for Android  |  Unity  |  Google for Developers

Please note that the Google Admob plug-in requires the gradle version. I am using the latest version here, so I used the 4.2.0 gradle plug-in.

Settings after importing max sdk unity plug-in package and google admob plug-in package into Unity:

 

 

The ID filled in is the application ID from Google Admob, not the advertising ID.

under the asset menu (Similarly fill in the Google Admob application id

Pitfalls: You will see an SDK KEY in the MAX aggregated advertising document. If you use the Chinese translation, it may be the wrong KEY. It is best to go to the aggregated advertising console to find your application SDK KEY and do not translate it. For Chinese, I checked that the wrong KEY has a capitalization problem. I need to turn on case recognition to check whether all KEYs are correct.

Aggregation Advertising MAX Console
AppLovin - Sign in

Google Admob Console
https://apps.admob.com/

Here to add an ad unit, pay attention to what types of ads must use specific APIs to load and display ads and the corresponding callbacks. If the ads cannot be loaded normally, it may be that the wrong API is used or the advertising ID is incorrect.

For example, if I chose the Rewarded type of rewarded advertising above, I must use the rewarded advertising API.

Google Admob must be associated here (Admob belongs to Google). It needs to fill in the App id and Ad Unit ID. This Ad Unit ID does not refer to the aggregated advertising ID of the aggregated advertising SDK we are creating now, but refers to the advertising ID of Google Admob.

This Google Advertising ID needs to go to the Admob console to create an ad unit and set the ad unit as mediation.​ 

Then you will get an advertising ID and set it to the aggregated advertising side.

When we use the API of the aggregated advertising SDK to load and display ads, we pass in the aggregated advertising ID instead of Google Admob's advertising ID. In fact, an aggregated advertising ID can be associated with the advertising IDs of multiple other platforms, and it will use a set of priority rules. Choose which platform to display ads on.

CPM Price is the revenue generated every thousand times an ad is played. I don’t understand this very well. I currently set it to 1 casually. 

Unity PlayerSetting related configuration:

Google platform requires 64-bit 

The main reason is that the Target API Level is automatically the highest, which is 34. The actual 33 meets the requirements of all packages.

Select these 4, and then go to Force Resolve and it will be successful instantly. In fact, it just adds some dependency configurations to mainTemplate.gradle. You must check the Custom Main Gradle Template option to do this, otherwise it will help you directly load the dependency files into Plugin/Android. folder (will be slow and may fail! Recommended)

The dependencies added to mainTemplate.gradle will help you download the dependencies when building the build, which will succeed quickly.

MainTemplate.gradle will automatically add the following configuration:
 

// Android Resolver Repos Start
([rootProject] + (rootProject.subprojects as List)).each { project ->
    project.repositories {
        def unityProjectPath = $/file:///**DIR_UNITYPROJECT**/$.replace("\\", "/")
        maven {
            url "https://maven.google.com"
        }
        maven {
            url "http://maven.aliyun.com/nexus/content/groups/public/" // Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:7
        }
        maven {
            url "https://maven.google.com/" // Assets/GoogleMobileAds/Editor/GoogleUmpDependencies.xml:7
        }
        mavenLocal()
        mavenCentral()
    }
}
// Android Resolver Repos End

dependencies {	
// Android Resolver Dependencies Start
    implementation 'com.applovin.mediation:google-adapter:[22.5.0.0]' // Assets/MaxSdk/Mediation/Google/Editor/Dependencies.xml:5
    implementation 'com.applovin:applovin-sdk:12.0.0' // Assets/MaxSdk/AppLovin/Editor/Dependencies.xml:4
    implementation 'com.google.android.gms:play-services-ads:[22.3.0]' // Assets/GoogleMobileAds/Editor/GoogleMobileAdsDependencies.xml:7
    implementation 'com.google.android.ump:user-messaging-platform:2.1.0' // Assets/GoogleMobileAds/Editor/GoogleUmpDependencies.xml:7
// Android Resolver Dependencies End
}

// Android Resolver Exclusions Start test
android {
  packagingOptions {
      exclude ('/lib/armeabi/*' + '*')
      exclude ('/lib/armeabi-v7a/*' + '*')
      exclude ('/lib/mips/*' + '*')
      exclude ('/lib/mips64/*' + '*')
      exclude ('/lib/x86/*' + '*')
      exclude ('/lib/x86_64/*' + '*')
  }
}
// Android Resolver Exclusions End

Because I wanted to download dependent resources directly to the project through Force Resolve, I changed the maven image path. The change place was Assets\GoogleMobileAds\Editor\GoogleMobileAdsDependencies.xml

<dependencies>
  <androidPackages>
    <androidPackage spec="com.google.android.gms:play-services-ads:[22.3.0]">
      <repositories>
        <repository>http://maven.aliyun.com/nexus/content/groups/public/</repository>
      </repositories>
    </androidPackage>
  </androidPackages>

  <iosPods>
    <iosPod name="Google-Mobile-Ads-SDK" version="~> 10.9">
      <sources>
        <source>https://github.com/CocoaPods/Specs</source>
      </sources>
    </iosPod>
  </iosPods>
</dependencies>

Change to http://maven.aliyun.com/nexus/content/groups/public/ Alibaba Cloud image, which can speed up downloading Google dependencies

Modify in baseProjectTemplate.gradle

            classpath 'com.android.tools.build:gradle:4.2.0'

 4.2.0 is the gradle plugin version, corresponding to gradle 6.7.1

The default version of the 2019 version of Unity project is version 3.4.0 corresponding to gradle 5.1.1
The gradle version and plug-in version used by the Android studio version (notes)_gradle version and gradle plug-in version -CSDN Blog

You can go to the project to view it. Use this check box to use the default gradle of the project. I directly replaced the default gradle.

Replace this folder

Gradle Distributions

 Download it, unzip it, find the lib folder and replace it directly.

In the final test, I connected to Google to log in, and then logged in to a Google mailbox normally to enter the game. The advertisement was played successfully. The problem was that the MUMU emulator 12 crashed when it finished playing the advertisement and clicked X to exit the advertisement...

Pitfalls: Some advertisements require you to turn on the global mode and change the node (Taiwan or Japan) to be normal. Otherwise, the load will not succeed and it will say that you have not filled it (actually it is false, and it will be fine again if you change the node or mode!)

Note: MAX SDK test equipment will be automatically deactivated after 7 days (after a certain period of time)! If it keeps failing, check to see if the test device is activated.

During the testing phase, you can directly add test equipment without connecting overseas.

AppLovin

 It is necessary to pay attention to the GAID added to the test device to be correct and not to write it wrong.

 

I will test and connect to Admob

Note that it is very SB. You can only add this device GAID once and bind it to a network. If you want to test other intermediary advertisements, such as Pangle, you have to change it or create a new simulator and bind the Pangle platform advertisement with a new GAID.

Note that after activating the test device, you have to wait a few minutes. Even the test advertisement will take a few seconds to load. If it doesn't work, connect to the node. If it still doesn't work, change the mode (global mode or rule mode). 

Guess you like

Origin blog.csdn.net/qq_39574690/article/details/134571949