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 Ads and Splash Ads
  • minSdkVersion 16 or later
  • compileSdkVersion 28 or later

Step 2.Import the TradPlus SDK#

  • 1.Download the TradPlus Android SDK
  • 2.Update your AndroidManifest.xml
  • 3.Optionally use Proguard
  • 4.Initialize the SDK

Option 1.Download the TradPlus Android SDK#

  • 2.Apps can import the TradPlus SDK and the third-party SDK platforms with a Gradle dependency that points to the Packaging System of TradPlus SDK. Or 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
  • res:Aggregate the resources that the third-party Network SDK must import

Option 2.Update your AndroidManifest#

Set the following permissions in your project's AndroidManifest.xml:

1.Permission configuration#

<!--Must have permission-->
<!--YouDao(China)、Sigmob(China)-->
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<!-- Pangle: If there is a video ad and it is played with textureView, please be sure to add this, otherwise a black screen will appear -->
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<!-- Optional permissions -->
<!-- Smaato -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<!-- Tapjoy、Pangle(China)、GDT(China)- -->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<!--Vungle、Adcolony、Pangle(China)-->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18"/>
<!--Mopub、GDT(China)、Pangle(China)-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<!--Adcolony -->
<uses-permission android:name="android.permission.VIBRATE"/>
<!--Pangle(China)、GDT(China)-->
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<!--Pangle(China)、GDT(China)-->
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>
<!--Pangle(China)-->
<uses-permission android:name="android.permission.GET_TASKS"/>

2.Set Activity Definitions#

(1)If Mitegral China-Mainland is aggregated (Only Support AndroidX),the following configuration must be added to AndroidManifest.xml#

<!--Android X China-Mainland Traffic app required, Oversea Traffic app can be ignore-->
<provider
android:name="com.mbridge.msdk.foundation.tools.MBFileProvider"
android:authorities="${applicationId}.mbFileProvider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/mb_provider_paths"/>
</provider>

That mb_provider_paths.xml has been written into the three-party aar resource package

(2)If Admob is aggregated, the following configuration must be added to AndroidManifest.xml (you can find your app ID in the AdMob UI).#

For details,update_your_androidmanifest

<application>
<!--Add your Google AdMob App ID-->
<!--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-3940256099942544~3347511713"/>
</application>

(3)If Applovin is aggregated, the following configuration must be added to AndroidManifest.xml (you can find your SDK Key in the AppLovin).#

For details,Where to get the AppId or SDK Key

<application>
<!--AppLovin -->
<!--Add your Applovin SDK Key-->
<meta-data
android:name="applovin.sdk.key"
android:value="YOUR_SDK_KEY_HERE" />
</application>

(4)If Tencent GDT is aggregated, the following configuration must be added to AndroidManifest.xml#

<provider
android:name="com.qq.e.comm.GDTFileProvider"
android:authorities="${applicationId}.gdt.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/gdt_file_path" />
</provider>

That gdt_file_path.xml has been written into the three-party aar resource package

(5)If Smaato is aggregated, your application targets Android 5.0 (API level 21) or higher, then you need to add the following line to your application AndroidManifest.xml file:#

For details,Smaato integration

<uses-feature android:name="android.hardware.location.network" />

(6)If Kuaishou is aggregated, the following configuration must be added to AndroidManifest.xml#

<permission
android:name="${applicationId}.permission.KW_SDK_BROADCAST"
android:protectionLevel="signature" />
<uses-permission android:name="${applicationId}.permission.KW_SDK_BROADCAST" />

(7)If YouDao is aggregated, the following configuration must be added to AndroidManifest.xml#

<provider
android:name="com.youdao.sdk.extra.common.AdDownloadProvider"
android:authorities="${applicationId}.youdaosdk"
android:exported="false"
android:grantUriPermissions="true" >
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/ad_download_paths" />
</provider>

That ad_download_paths.xml has been written into the three-party aar resource package

(8)If Joomob is aggregated, the following configuration must be added to AndroidManifest.xml#

<provider
android:name="com.joomob.sdk.common.FileProvider"
android:authorities="${applicationId}.uniplay.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/uniplay_file_path" />
</provider>

That uniplay_file_path.xml has been written into the three-party aar resource package

3.Android 9 Adaptation#

(1)added the following configuration in AndroidManifest.xml:

<application>
...
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
...
</application>

(2)Add a network security configuration file The Network Security Configuration feature uses an XML file where you specify the settings for your app. If you haven't done so, under the xml folder of the app resources, you can create a new XML file: res/xml/network_security_config.xml. Then in your application manifest AndroidManifest.xml, add the configuration to your application attribute as follows:

<application>
...
android:networkSecurityConfig="@xml/network_security_config">
...
</application>

For more details regarding the Network security configuration, please see the official Google documentation

In the res/xml/network_security_config.xml file, you can add localhost to the permitted cleartext traffic domain by adding:

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>

Option 3.ProGuard Configuration#

Add the following to your ProGuard configuration:

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

Option 4.Initialize the SDK#

You can initialize the TradPlus SDK in your Application:

  • V6.X New API
//Create your TradPlus Apps and get your AppId
TradPlusSdk.initSdk(context,"APPID");
  • V5.X Old API
//Create your TradPlus Apps and get your AppId
TradPlus.invoker().initSDK(context,"APPID");

You can get "APPID" , as shown below: