In this documentation we explained how to use Huawei-Applovin mediation plugin developed by Applovin. Plugin repository link is here
Banner Ad | Interstitial Ad | Rewarded Ad | Native Ad | MREC | |
---|---|---|---|---|---|
Native (Java/Kotlin) | ✅ | ✅ | ✅ | ✅ | ✅ |
Unity | ✅ | ✅ | ✅ | ❌ | ✅ |
- Sign in to Huawei Developer Console and create an AdUnit
-
Sign in to Applovin dashboard
-
Go to "Networks -> Click here to add a Custom Network"
-
Select "SDK as Network Type" and give your custom network a name.
-
Enter the class name "com.applovin.mediation.adapters.HuaweiMediationAdapter" for Android/FireOS Adapter Class Name.
-
Enter "HuaweiMediationAdapter" for iOS Adapter Class Name
-
Go to "Ad Units" tab, and create a new ad unit or modify the existing one.
-
On "Default Waterfall" section below the "Custom Networks & Deals" enable the Huawei network.
-
Enter the Huawei Ad unit ID for Placement ID and Enter CPM price for the waterfall.
Note: This link also can be useful.
In the project-level build.gradle, include Huawei's Maven repository.
repositories {
maven { url 'https://developer.huawei.com/repo/' } // Add this line
}
...
allprojects {
repositories {
maven { url 'https://developer.huawei.com/repo/' } //Add this line
}
}
dependencies {
implementation 'com.applovin.mediation:huawei-adapter:<latest-version>'
}
Check the latest version of adapter here
Important Note : Applovin-Huawei adapter released and maintained by Applovin team. Please use this repository if you have any issues or feedbacks related to Huawei adapter.
The HUAWEI Ads SDK (com.huawei.hms:ads) has integrated the required permissions. Therefore, you do not need to apply for these permissions.
android.permission.ACCESS_NETWORK_STATE: Checks whether the current network is available.
android.permission.ACCESS_WIFI_STATE: Obtains the current Wi-Fi connection status and the information about WLAN hotspots.
android.permission.BLUETOOTH: Obtains the statuses of paired Bluetooth devices. (The permission can be removed if not necessary.)
android.permission.CAMERA: Displays AR ads in the Camera app. (The permission can be removed if not necessary.)
android.permission.READ_CALENDAR: Reads calendar events and their subscription statuses. (The permission can be removed if not necessary.)
android.permission.WRITE_CALENDAR: Creates a calendar event when a user clicks the subscription button in an ad. (The permission can be removed if not necessary.)
Before building the APK, configure the obfuscation configuration file to prevent the HUAWEI Ads SDK () from being obfuscated.
Open the obfuscation configuration file proguard-rules.pro in the app-level directory of your Android project, and add configurations to exclude the HUAWEI Ads SDK from obfuscation.
-keep class com.huawei.openalliance.ad.** { *; }
-keep class com.huawei.hms.ads.** { *; }
To allow HTTP and HTTPS network requests on devices with targetSdkVersion 28 or later, configure the following information in the AndroidManifest.xml file :
<activity
...
android:usesCleartextTraffic="true"
>
...
</activity>
Banner Ad type fixed.
Banner and MREC adapter classes are added.
Interstitial,rewarded and native adapter classes are added.
This section demonstrates how to use Applovin mediation feature with Huawei Ads Kit on Native android app.
Firstly, integrate the Applovin-MAX SDK for Android
Applovin-MAX Android SDK can be used for all ad types.
Note :
- Developers can find app level build.gradle in their project from "app-folder/app/build.gradle"
- If you use the native ad format in your application, please submit a ticket here to get support from Huawei.
To use Banner ads in Native android apps, please check the Applovin-MAX SDK. Click here to get more information about Applovin-MAX SDKs Banner Ad development.
To use Interstitial ads in Native android apps, please check the Applovin-MAX SDK. Click here to get more information about Applovin-MAX SDKs Interstitial Ad development.
To use Rewarded ads in Native android Rewarded, please check the Applovin-MAX SDK. Click here to get more information about Applovin-MAX SDKs Rewarded Ad development.
To use Native ads in Native android apps, please check the Applovin-MAX SDK. Click here to get more information about Applovin-MAX SDKs Native Ad development.
To use MREC ads in Native android apps, please check the Applovin-MAX SDK. Click here to get more information about Applovin-MAX SDKs MREC Ad development.
Note: Enter Huawei 300x250 Banner slot ID for Applovin MREC ad type.
This section demonstrates how to use Applovin mediation feature with Huawei Ads Kit on Unity.
Make sure to check the article on How to use Huawei Ads with Supported Ad Platforms in Unity ? to learn how to implement Huawei Ads in Unity platform.
Supported Ad Formats are: Banner Ads, Interstitial Ads, Rewarded Ads and MREC Ads.
Firstly, integrate the Applovin Unity SDK to Unity.
For more details on Applovin Unity SDK visit here
To use Banner ads in Unity , please check the Applovin Unity SDK. Click here to get more information about Applovin Unity SDKs Banner Ad development.
To use Interstitial ads in Unity, please check the Applovin Unity SDK. Click here to get more information about Applovin Unity SDKs Interstitial Ad development.
To use Rewarded ads in Unity, please check the Applovin Unity SDK. Click here to get more information about Applovin Unity SDKs Rewarded Ad development.
To use Medium Rectangle ads in Unity , please check the Applovin Unity SDK. Click here to get more information about Applovin Unity SDKs Medium Rectangle Ad development.
Make sure to switch to the Android Platform from Build Settings -> Android -> Switch Platform
Edit -> Project Settings -> Player -> Other Settings
In Other Settings set minimum API level to at least 21.
Edit -> Project Settings -> Player -> Publishing Settings
In Publishing Settings select “Custom Main Gradle Template” , “Custom Base Gradle Template” and “Custom Greadle Properties Template”
This will let you override mainTemplate.gradle , baseProjectTemplate.gradle and gradleTemplate.properties files in the project.
baseProjectTemplate.gradle is equal to project-level gradle so you have to include Huawei's Maven repositories from the Integrate the Huawei Mediation SDK section from here
mainTemplate.gradle is equal to app-level build.gradle so you have to include dependencies from the Integrate the Huawei Mediation SDK section from here.
Open gradleTemplate.properties and add the following lines
android.useAndroidX=true
android.enableJetifier=true
After these configurations is completed you can display Huawei Ads.
Note: In case of any error on aaptOptions you can add the following line to aaptOptions in launcherTemplate.gradle which you override it by enabiling it from Edit -> Project Settings -> Player -> Publishing Settings
aaptOptions {
noCompress = ['.ress', '.resource', '.obb'] + unityStreamingAssets.tokenize(', ')
ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
}
This section demonstrates how to use Applovin mediation feature with Huawei Ads Kit on Unity android app.
Banner Ad |
Interstitial Ad |
Rewarded Ad |
Native Ad |
Medium Rectangle Ad |