Skip to main content

Initialize the TradPlus SDK

Step 1.Prerequisites#

This document mainly introduces how to integrate TradPlus SDK.

  • The supported ad formats are: Native Ads、Banner Ads, Interstitial Ads, Rewarded Video Ads
  • minSdkVersion 16 or later
  • compileSdkVersion 28 or later

Step 2.Import the TradPlus SDK#

  • 1.Download the TradPlus Unity3dAndroid SDK
  • 2.Android SDK Import Instructions
  • 3.Optionally use Proguard
  • 4.Initialize the SDK

Step 3.Download the TradPlus Unity3dAndroid SDK#

  • 2.Select the Integrate to generate Gradle's integration code as shown below:

  • 3.Select the SDK download link as shown below:

Download the SDK zip package.After decompression,the TradPlusSDK_Android folder will have the following contents:

  • third-party_libs:You can obtain the SDK library files in this folder
    • Use the androidX libraries:You can obtain the SDK library files about Pangle and Tencent GDT 's aar in this folder
    • Use the original support libraries:You can obtain the SDK library files about Pangle , Tencent GDT and Vungle's aar in this folder
  • unity_assets:You can obtain the cs script file
  • res:Aggregate the resources that the third-party Network SDK must import

Step 4.Android SDK Import Instructions#

Option 1.Editor 2019 and above configuration#

(1)Generate Gradle and AndroidManifest.xml#

As shown below,generate baseProjectTemplate.gradlemainTemplate.gradle and AndroidManifest.xmlfile

(2)baseProjectTemplate.gradle configuration#

In baseProjectTemplate.gradle file, you can import the TradPlus SDK and the third-party SDK platforms with a Gradle dependency that points to the Packaging System of TradPlus SDK.

For an example :

allprojects {
buildscript {
repositories {**ARTIFACTORYREPOSITORY**
google()
jcenter()
//TradPlus Maven
maven { url 'https://dl.bintray.com/tradplus/support' }
}
...
}
repositories {**ARTIFACTORYREPOSITORY**
google()
jcenter()
//TradPlus Maven
maven { url 'https://dl.bintray.com/tradplus/support' }
flatDir {
dirs "${project(':unityLibrary').projectDir}/libs"
}
}
}
...
(2)mainTemplate.gradle configuration#

In mainTemplate.gradle file, you can import the TradPlus SDK and the third-party SDK platforms with a Gradle dependency that points to the Packaging System of TradPlus SDK.

apply plugin: 'com.android.library'
**APPLY_PLUGINS**
dependencies {
//Tips:Introduced according to the configuration of each version
//TradPlus Maven Support
implementation 'com.tradplus.ads:tradplus-sdk:6.0.1'
implementation 'com.tradplus.ads:tradplus-core:6.0.1'
implementation 'com.tradplus.ads:tradplus:6.0.1'
//Admob
implementation 'com.google.android.gms:play-services-ads:17.2.1'
implementation 'com.tradplus.ads.google:tradplus-google:2.6.0.1'
//Facebook
implementation 'com.facebook.android:audience-network-sdk:6.2.0'
implementation 'com.tradplus.ads.facebook:tradplus-facebook:1.6.0.1'
**DEPS**}
...

(3)AndroidManifest.xml configuration#

Please following AndroidManifest.xml configuration file to configure.


Option 2.Editor 2018 configuration#

(1)Generate mainTemplate.gradle file#

WeChatWorkScreenshot_0767252a-d886-49b8-afb7-19680a49ea77.png

Please following the Packaging System of TradPlus SDK to configure

(2)Generate AndroidManifest.xml file#

In the installation directory of unity, you can find the default Manifest file of unity, and copy it to the same level directory where you generated mainTempate.gradle. Please following AndroidManifest.xml configuration file to configure.

Step 5.AndroidX Configuration#

Generate gradleTemplate.properties file,as shown below:

In gradleTemplate.properties file, you need to add this:

android.enableJetifier=true
android.useAndroidX=true

Or you can add new SupportAndroidXGradlePropertiesBuildProcessor.cs files in the project’s Assets/Plugins/Editor :

using System.IO;
using UnityEditor.Android;
using UnityEngine;
public class SupportAndroidXGradlePropertiesBuildProcessor : IPostGenerateGradleAndroidProject
{
public int callbackOrder
{
get { return 999; }
}
public void OnPostGenerateGradleAndroidProject(string path)
{
Debug.Log("Bulid path : " + path);
string gradlePropertiesFile = path + "/gradle.properties";
if (File.Exists(gradlePropertiesFile))
{
File.Delete(gradlePropertiesFile);
}
StreamWriter writer = File.CreateText(gradlePropertiesFile);
writer.WriteLine("org.gradle.jvmargs=-Xmx4096M");
writer.WriteLine("android.useAndroidX=true");
writer.WriteLine("android.enableJetifier=true");
writer.Flush();
writer.Close();
}
}

Step 6.ProGuard Configuration#

Add the following to your ProGuard configuration:

-keep public class com.tradplus.** { *; }
-keep class com.tradplus.ads.** { *; }

Step 7.Initialize the SDK#

Initialize TradPlus in the game launch class:

//Create your TradPlus Apps and get your AppId
TradPlus.InitializeSdk(“AppId“);

You can get "APPID" , as shown below: