
3. ReferenceAndroid Demo Github address (click to jump)
Demo directory description:
| Directory | Description |
|---|---|
| China | Demo directory in Mainland China< /td> |
| NonChina | Demo of non-China AAR/JAR integration method |
| NonChina_Jcenter | Gradle integration method Demo for non-Mainland China |
The integration method in the Demo is for reference only. The description of each Activity is as follows:
| Activity | Description |
|---|---|
| RewardVideoAdActivity | Rewarded Video |
| InterstitialAdActivity | Interstitial screen/interstitial video/full screen video |
| NativeAdActivity | Native/Information Flow/Draw Ads |
| BannerAdActivity | Banner ads |
| SplashAdActivity, SplashAdShowActivity | Open screen advertisement |
Note: When integrating Android projects, mainland China and non-mainland China must subcontract the integration, otherwise integration conflicts will occur.
Note: Developers are asked to go to the packaging system page below to regenerate the Gradle import code and access it. The new warehouse supports at least version v5.7.21. If developers still need to use an SDK lower than this version, please integrate it through an aar package.
(1) Enter TopOn SDKPackaging system, select the non-Mainland China option and check gradle access, check the third-party advertising platform that needs to be aggregated, as shown below:
Select the third-party SDK platform that needs to be aggregated, and then click the button in the upper right corner[Integrate]To generate Gradle integration code, AndroidManifest configuration and SDK download link, as shown below:
Since some third-party advertising SDKs do not currently support Gradle integration, the SDK package will still provide the AAR/JAR library files of the third-party SDK. You can download our SDK Then get it in libs. (The content displayed on the front-end page can also be obtained in the folder after downloading the SDK)
(2) Download the compressed package of SDK and decompress it into release_folder(xxxxxxxxx) There will be the following content in the folder:
| Directory/File | Description |
|---|---|
| libs | Some third-party advertising platforms do not support Gradle integration, which can be obtained in this folder SDK library file |
| build.gradle | Code content that needs to be integrated by project gradle |
| AndroidManifest.xml | The components and configuration information in AndroidManifest need to be added to the AndroidManifest of the development project (no configuration is required if the file does not exist) |
| proguard-android.txt | Confusion Configuration (no configuration required if the file does not exist) |
| res | Aggregation of resources that must be imported by the third-party Network SDK (if there are, copy all the folders inside to the res directory of the project, if not, there is no need to import them) |
| keep.xml | If packed If shrinkResources is enabled or some third-party resource optimization framework is connected (such as AndResProguard), the resources in this file must be added to the whitelist, Otherwise it will cause a crash or advertising exception |
( 3) To use Gradle’s introduction method, the project must use Google’s AndroidX library package, where The project cannot include Google's Support library package, otherwise the third-party advertising platform may not be properly integrated. The AndroidX library package is integrated as follows:
android {
//CompileSdkVersion requires a minimum of 28
compileSdkVersion 28
}
dependencies {
//Androidx(Necessary)
api 'androidx.appcompat:appcompat:1.1.0'
api 'androidx.browser:browser:1.0.0'
api 'androidx.recyclerview:recyclerview:1.1.0'
}In the project gradle.propertiesThe new configuration is as follows:
android.enableJetifier=true
android.useAndroidX=true(4) If there is aggregation Pangle, Facebook, Inmobi, etc. Advertising platforms (some advertising platforms support Gradle plugin version), please check whether the version of Gradle plugin you are using is One of the following versions, otherwise an error will be reported during the compilation phase. Please confirm the Gradle version you are using and follow the corresponding relationship between Gradle Plugin and Gradle Update to one of the following Gradle plugin versions: (For example, if you are using Gradle v5.4.1+, update the Gradle plugin version to v3.5.4)
(1) Enter TopOn SDK's Packaging system, select an option other than Mainland China and not Gradle integration method, check the third-party advertising platform that needs to be aggregated, as shown below:
Select the third-party SDK platform that needs to be aggregated, and then click the button in the upper right corner[ Integrate] to generate the SDK download link.
(2) Download the SDK compressed package and unzip itrelease_folder(xxxxxxxxx) There will be the following content in the folder:
| Directory/File | Description |
|---|---|
| libs | Aggregate the package directory that must be integrated by the third-party Network SDK (place the aar and jar inside libs directory of the development project) |
| build.gradle | Code content that needs to be integrated by project gradle |
| AndroidManifest.xml | The components and configuration information in AndroidManifest need to be added to the AndroidManifest of the development project (no configuration is required if the file does not exist) |
| proguard-android.txt | Confusion configuration (no configuration required if the file does not exist) |
| res | Aggregate resources that must be imported by the third-party Network SDK (if there are, copy all the folders inside to the res directory of the project, if not, no need to import) |
When there are many aggregated advertisements, libs folder and res folderThere may be a lot of files. It is recommended to create two files in the project at the same level as libs A new file directory, for example, create topon_libs and topon_res folder, put the compressed package libs, and then introduce it in gradle:
android {
....
sourceSets {
main {
res.srcDirs += 'topon_res'
}
}
...
}
dependencies {
api fileTree(include: ['*.jar','*.aar'], dir: 'topon_libs')
}This processing facilitates subsequent SDK update processing and will not mix the SDK resource files with the project's resource files.
(3) The project must use GoogleAndroidX library package, Google’s Support< cannot be used in the project /span> library package, otherwise the third-party advertising platform cannot be integrated properly. The AndroidX library package is integrated as follows:
android {
//CompileSdkVersion requires a minimum of 28
compileSdkVersion 28
}
dependencies {
//Androidx(Necessary)
api 'androidx.appcompat:appcompat:1.1.0'
api 'androidx.browser:browser:1.0.0'
api 'androidx.recyclerview:recyclerview:1.1.0'
}In the project gradle.propertiesThe new configuration is as follows:
android.enableJetifier=true
android.useAndroidX=true(4) Starting from v5.7.06, if you have v5.15.0 and above that aggregate MoPub, you need to add The following dependencies:
dependencies {
api 'androidx.media2:media2-session:1.0.1'
api 'androidx.media2:media2-widget:1.0.1'
api 'androidx.media2:media2-player:1.0.1'
api 'androidx.core:core-ktx:1.1.0'
api 'org.jetbrains.kotlin:kotlin-android-extensions-runtime:1.3.61'
}(5) Starting from v5.7.24 For versions before v5.7.42, if you have the v15.4.7 version of Mintegral, you need to add the following dependencies:
dependencies {
api 'com.google.android.exoplayer:exoplayer-core:2.12.2'
}(6) If there are aggregation advertising platforms such as Pangle, Facebook, and Immobi (some advertising platforms have requirements for the version of Gradle plugin), please check if the version of Gradle plugin you are using is one of the following versions, otherwise an error will be reported during the compilation phase. Please confirm the version of Gradle you are using and update it to one of the following Gradle plugin versions based on the correspondence between Gradle Plugin and Gradle: (For example, if you are using Gradle v5.4.1+, update the version of Gradle plugin to v3.5.4)
3.3.3, 3.4.3, 3.5.4, 3.6.4, 4.0.1
1、The required permissions for TopOn SDK are as follows:
<-- TopOn SDK General Necessary Permissions -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<-- Non China SDK Required Permissions -->
<uses-permission android:name="com.google.android.gms.permission.AD_ID" />Attention: The required permissions for advertising platforms must be configured with the AndroidManifest.xml content in the downloaded SDK compressed package to your project
<manifest>
<application>
<!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-xxxxxxxxxxxxxxxx~yyyyyyyyyy"/>
</application>
</manifest>
For details, please refer to the Adnob configuration document: Update your AndroidManifest.xml
Some advertising platforms have an SO library in their SDKs, and the architectures supported by the SO files used by each platform are as follows: (Developers can choose the following architectures as needed)
Csj: arm64-v8a, armeabi-v7a
KuaiShou ads: arm64-v8a, armeabi-v7a, armeabi, x86_ 64, x86
Suggestion: Add the following configuration in build.gradle to support most mobile architectures:
defaultConfig {
...
ndk{
abiFilters 'armeabi-v7a','x86'
}
}
Note: The following is the confusion configuration for TopOn SDK. The confusion configuration for advertising platforms must refer to the proguard-android.txt file in the downloaded SDK compression package
-keep public class com.anythink.**
-keepclassmembers class com.anythink.** {
*;
}
-keep public class com.anythink.network.**
-keepclassmembers class com.anythink.network.** {
public *;
}
-dontwarn com.anythink.hb.**
-keep class com.anythink.hb.**{ *;}
-dontwarn com.anythink.china.api.**
-keep class com.anythink.china.api.**{ *;}
# new in v5.6.6
-keep class com.anythink.myoffer.ui.**{ *;}
-keepclassmembers public class com.anythink.myoffer.ui.** {
public *;
}
If you have enabled shrinkResource, you need to add a keep.XML file in the res/raw path, which contains the content of the SDK's compressed package's keep.XML file. An example is as follows (click to view Android resource optimization processing):
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools"
tools:keep="@layout/anythink_*,@string/anythink_*,@drawable/anythink_*,@id/anythink_*,@dimen/anythink_*,@style/anythink_*,@color/anythink_*,@anim/anythink_*"
tools:shrinkMode="safe" />
If some third-party resource optimization frameworks are introduced (such as AndResProguard), all resources prefixed with anything need to be added to the whitelist, for example:
R.string.anythink_*
R.drawable.anythink_*
R.layout.anythink_*
R.id.anythink_*
R.dimen.anythink_*
R.style.anythink_*
R.color.anythink_*
R.anim.anythink_*
(1)Add the following configuration in Android Manifest:
<application>
...
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
...
</application>(1)Add code for Webview settings at the beginning of Application # onCreat() (which must be set before initializing other third-party SDKs):
public class * extends Application {
@Override
public void onCreate() {
super.onCreate();
//Android 9 and above must be set up
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
String processName = getProcessName();
if (!getPackageName().equals(processName)) {
WebView.setDataDirectorySuffix(processName);
}
}
...
}
}(2)The Google documentation explains as follows:
If your application must use WebView instances in multiple processes, you must first use the WebView. setDataDirectorySuffix() method to specify a unique data directory suffix for each process, and then use the given instance of WebView in the corresponding process. This method will put the network data of each process into its own directory within the application data directory.
Before any WebView instance in the process is created, and before calling any other method in the android.webkit package in this process, you must first call WebView. setDataDirectorySuffix() to set the data directory of the process.

8. Advertising test instructions