Help Center/Details/

SDK Embedding Configuration

Android integration

Note: This version of the SDK is not applicable to Android stores/channels outside of China. If developers have overseas data connection needs, please send an email to pangle_support@bytedance.com to get the correct overseas exclusive Android SDK version for connection.

SDK integration

Application CodeId

Please create the application ID and advertising slot ID on the CSJ platform

Method 1: Import the jar packages that aar and SDK depend on

Copy the open_ad_sdk.aar in the SDK compressed package to the Application Module/libs folder (if not, you must create it manually), and add the following code to your app’s build.gradle:

repositories {
    flatDir {
        dirs 'libs'
    }
}
depedencies {
    compile(name: 'open_ad_sdk', ext: 'aar')
}

Way two:

Starting from version 3.5.0.6 of CSJ, developers can also use Gradle dependencies to import CSJ SDK

Step 1: Add a warehouse
Add a reference to Maven in the build.gradle file at the project level, url'https://artifact.bytedance.com/repository/pangle'
Example:

allprojects {
    repositories {
        maven {
          url 'https://artifact.bytedance.com/repository/pangle'
            }
      }
}

Step 2: Add dependencies
Add SDK dependencies to the build.gradle file of the main module

dependencies {
    implementation 'com.pangle.cn:ads-sdk:3.5.0.6'
}

Special note
If you are integrating the CSJ Pro version of the SDK, you can introduce the SDK in the following ways

// rep
maven {
          url 'https://artifact.bytedance.com/repository/pangle'
      }
      
// dependencies
dependencies {
    implementation 'com.pangle.cn:ads-sdk-pro:3.7.0.4'
}  

Gradle version requirements:
Since version 3400, CSJ support Android R, and the <queries data-tomark-pass=""> tag of Android R is introduced. The gradle version needs to be restricted. The restricted range is: 3.3.3, 3.4.3, 3.5.4, 3.6.4, 4.0. 1. Developers can upgrade according to their own circumstances</queries>

AndroidManifest configuration

Add permissions

<!--必要权限-->
<uses-permission android:name="android.permission.INTERNET"  data-tomark-pass />

<!--必要权限,解决安全风险漏洞,发送和注册广播事件需要调用带有传递权限的接口-->
<permission      android:name="${applicationId}.openadsdk.permission.TT_PANGOLIN"
        android:protectionLevel="signature"  data-tomark-pass />

    <uses-permission android:name="${applicationId}.openadsdk.permission.TT_PANGOLIN"  data-tomark-pass /> 
   

<!--可选权限-->
<uses-permission android:name="android.permission.READ_PHONE_STATE"  data-tomark-pass />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"  data-tomark-pass />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"  data-tomark-pass />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"  data-tomark-pass />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"  data-tomark-pass />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" data-tomark-pass />
<uses-permission android:name="android.permission.GET_TASKS" data-tomark-pass />

<!--可选,穿山甲提供“获取地理位置权限”和“不给予地理位置权限,开发者传入地理位置参数”两种方式上报用户位置,两种方式均可不选,添加位置权限或参数将帮助投放定位广告-->
<!--请注意:无论通过何种方式提供给穿山甲用户地理位置,均需向用户声明地理位置权限将应用于穿山甲广告投放,穿山甲不强制获取地理位置信息-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"  data-tomark-pass />

<!-- 如果视频广告使用textureView播放,请务必添加,否则黑屏 -->
<uses-permission android:name="android.permission.WAKE_LOCK"  data-tomark-pass />

<!--demo场景用到的权限,不是必须的-->
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT"  data-tomark-pass />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"  data-tomark-pass />
<uses-permission android:name="android.permission.EXPAND_STATUS_BAR"  data-tomark-pass />

<!-- 穿山甲3400版本新增:建议添加“query_all_package”权限,穿山甲将通过此权限在Android R系统上判定广告对应的应用是否在用户的app上安装,避免投放错误的广告,以此提高用户的广告体验。若添加此权限,需要在您的用户隐私文档中声明! -->
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" data-tomark-pass />

Note: The CSJ SDK does not compulsorily obtain the above permissions, and the SDK can run normally even if the optional permissions are not obtained; obtaining the above permissions will help CSJ optimize the advertising accuracy and user interaction experience, and improve eCPM.
It is recommended to call the method provided by the SDK at an appropriate time before the ad request, and obtain the permission in the statement when the user can authorize, so as to improve the efficiency of ad monetization

//TTAdManager接口中的方法,context可以是Activity或Application
void requestPermissionIfNecessary(Context context);

provider configuration

Note:
(1) In order not to affect the use of download type advertisements, the provider needs to be configured normally in the manifest file regardless of the APP at any stage
(2) In order not to affect the conversion and revenue of the advertisement, please be sure to configure xxx.TTMultiProvider in the manifest file
Adapt to Anroid7.0 and above
If your application needs to run in Anroid7.0 and above, please add the following code in AndroidManifest:

<provider
    android:name="com.bytedance.sdk.openadsdk.TTFileProvider"
    android:authorities="${applicationId}.TTFileProvider"
    android:exported="false"
    android:grantUriPermissions="true" data-tomark-pass >
   <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/file_paths"  data-tomark-pass />
</provider>

In the res/xml directory, create a new xml file file_paths, and add the following code to the file:

<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android" data-tomark-pass >
   <!--为了适配所有路径可以设置 path = "." -->
   <external-path name="tt_external_root" path="."  data-tomark-pass />
   <external-path name="tt_external_download" path="Download"  data-tomark-pass />
   <external-files-path name="tt_external_files_download" path="Download"  data-tomark-pass />
   <files-path name="tt_internal_file_download" path="Download"  data-tomark-pass />
   <cache-path name="tt_internal_cache_download" path="Download"  data-tomark-pass />
</paths>

In order to adapt to download and install related functions, the package referenced in the project is com.android.support:support-v4:24.2.0
Use 24.2.0 and above
Note: Single process or multiple processes must be configured

<provider
android:name="com.bytedance.sdk.openadsdk.multipro.TTMultiProvider"   android:authorities="${applicationId}.TTMultiProvider"   android:exported="false"  data-tomark-pass />

Operating environment configuration

This SDK can run on Android4.0 (API Level 14) and above.

<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="24"  data-tomark-pass />

If the developer declares that the targetSdkVersion is above API 23, please make sure that you have applied for all the permissions required by the SDK before calling any interface of this SDK, otherwise some features of the SDK may be restricted

Code obfuscation

If you need to use proguard to obfuscate the code, make sure not to obfuscate the SDK code. Please add the following configuration at the end of the proguard.cfg file (or other obfuscated files):

The obfuscation rules for 35xx and the following versions are as follows:

-keep class com.bytedance.sdk.openadsdk.** { *; }
-keep public interface com.bytedance.sdk.openadsdk.downloadnew.** {*;}
-keep class com.pgl.sys.ces.* {*;}
-keep class com.bytedance.embed_dr.** {*;}
-keep class com.bytedance.embedapplog.** {*;}

The obfuscation rules for versions 36xx-38xx are as follows:

-keep class com.bytedance.sdk.openadsdk.** { *; }
-keep public interface com.bytedance.sdk.openadsdk.downloadnew.** {*;}
-keep class ms.bd.c.**{*;}
-keep class com.bytedance.mobsec.**{*;} 
-keep class com.bytedance.embed_dr.** {*;}
-keep class com.bytedance.embedapplog.** {*;}
-keep interface com.bytedance.frameworks.baselib.network.http.cronet.I* {*;}
-keepnames class com.bytedance.framwork.core.sdkmonitor.SDKMonitorUtils

The obfuscation rules for version 3900 and above are as follows:

-keep class com.bytedance.sdk.openadsdk.** { *; }
-keep class com.bytedance.frameworks.** { *; }

-keep class ms.bd.c.Pgl.**{*;}
-keep class com.bytedance.mobsec.metasec.ml.**{*;}

-keep class com.ss.android.**{*;}

-keep class com.bytedance.embedapplog.** {*;}
-keep class com.bytedance.embed_dr.** {*;}

-keep class com.bykv.vk.** {*;}

Note: If the SDK code is obfuscated, it will cause ads to not be displayed or other abnormalities
Support structure
Note: The SDK of 3900 and above versions supports armeabi-v7a and arm64-v8a by default. If you have other architecture requirements, please contact technical support students; the so file used in SDK versions below 3900 supports five architectures: x86, x86_64, armeabi, armeabi-v7a, arm64-v8a if your application
The supported architectures exceed these five, please use abiFilters in build.gradle to select the supported architectures. As shown below:

ndk { // 设置支持的 SO 库构架,注意这里要根据你的实际情况来设置 
   abiFilters 'armeabi-v7a', 'arm64-v8a', x86', x86_64', 'armeabi'
}

Description:

  1. The libmetasec_ml.so library was added to CSJ in version 3600.
  2. If the developer of version 3600 uses the armeabi architecture, then you need to copy the'libmetasec_ml.so' under armeabi-v7a to the armeabi directory for use.

Whitelist configuration

Note: The resources on the whitelist.txt in the platform SDK package do not support obfuscation
1111.png

Did the content solve your problem?
Contact us