Basic SDK information
SDK name | Version number | md5 | Package name |
AMP crash SDK | Latest version: apm-crash:2.0.1 | b26b2fbb9d781b73c93e4b50b4444fc0 | com.lydaas.qtsdk:apm-crash |
AMP efs SDK | Latest version: apm-efs:2.1.0 | 2b54c6db27acc24081fbd07fc6f3c86e | com.lydaas.qtsdk:apm-efs |
gradle plug-in | Latest version: gradle7 + : apm-plugin:2.0.1 gradle7 following version: apm-plugin:1.0.1 | 2.0.1:eae067a2283ee6c940be516a0fed0962 1.0.1: 2dcdbe7ee400ea07ef7b2dd355c0ae65 | com.lydaas.qtsdk:apm-plugin |
1. Introduce the SDK
1.1 Maven Address Configuration&Introduction of the Performance Analysis Gradle Plugin
Gradle of a lower version
Add the URL of the sdk maven repository to the buildscript and allprojects code snippet in the build.gradle configuration script of the project.
On-demand introduction of the apm performance analysis gradle plug-in in dependencies
buildscript {
repositories {
maven { setUrl("https://repo1.maven.org/maven2/") }
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
// Add the Gradle plug-in of the Gradle7 + version to the Apm performance analysis module as needed.
classpath 'com.lydaas.qtsdk:apm-plugin:2.0.1'
// Add the Gradle plug-in to Gradle7 or later.
classpath 'com.lydaas.qtsdk:apm-plugin:1.0.1'
}
}
allprojects {
repositories {
maven { setUrl("https://repo1.maven.org/maven2/") }
google()
jcenter()
}
}Introduce the plug-in to the build.gradle file of the project app.
apply plugin: 'com.efs.sdk.plugin'AGP7 and above
Add the code repository address to the settings.gradle file in the project.
pluginManagement {
repositories {
google {
content {
includeGroupByRegex("com\\.android.*")
includeGroupByRegex("com\\.google.*")
includeGroupByRegex("androidx.*")
}
}
mavenCentral()
gradlePluginPortal()
maven { url 'https://repo1.maven.org/maven2/' }
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://repo1.maven.org/maven2/' }
}
}Introduce the apm performance analysis gradle plug-in to the build.gradle configuration corresponding to the project app as needed.
buildscript {
dependencies {
classpath 'com.lydaas.qtsdk:apm-plugin:2.0.1'
}
}
plugins {
alias(libs.plugins.android.application)
}
apply plugin: 'com.efs.sdk.plugin'1.2 Component Reference
Add component library dependencies to the dependencies section of the build.gradle configuration script corresponding to the project App.
The integrated SDKs of the PX series need to be integrated with the APM SDK of the SMIC version. You can use the following integration:
dependencies {
implementation fileTree(include:['*.jar'], dir:'libs')
// Integrate the statistical analysis SDK.
implementation 'com.lydaas.qtsdk:qt-px-common:1.8.5.PX'
// Apm stability SDK library
implementation 'com.lydaas.qtsdk:apm-crash:2.0.1'
// Apm performance SDK library
implementation 'com.lydaas.qtsdk:apm-efs:2.1.0'
}If you have integrated the P series unified SDK, integrate the following versions of APM SDK:
dependencies {
implementation fileTree(include:['*.jar'], dir:'libs')
// Integrate the statistical analysis SDK.
implementation 'com.lydaas.qtsdk:qt-common:1.6.1.P'
// Apm stability SDK library
implementation 'com.lydaas.qtsdk:apm-crash:1.5.2.1.0.0.3'
// Apm performance SDK library
implementation 'com.lydaas.qtsdk:apm-efs:1.6.0.001.210'
}2. Configure permissions
The host application must be granted the following permissions:
Permissions | Usage |
ACCESS_NETWORK_STATE | Detects the networking mode and avoids data sending in abnormal network conditions to save traffic and power. |
ACCESS_WIFI_STATE | Obtain the WIFI mac address. On a tablet device or TV box, the device cannot be identified by IMEI. We will use the WIFI mac address as the unique identifier of the user in order to provide statistical analysis services normally. |
INTERNET | Permissions that allow applications to network and send statistical data in order to provide statistical analysis services. |
READ_PHONE_STATE (optional) | The IMEI of the user equipment is obtained, and the user is uniquely identified by the IMEI, so as to provide a statistical analysis service. |
An example AndroidManifest.xml manifest file is given below:
<manifest ……>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<application ……> 3. Obfuscation configuration
If your application uses code obfuscation, add the following configurations to prevent the SDK from being incorrectly obfuscated.
-keep class com.umeng.** {*;}
-keep class com.uc.** { *; }
-keep class com.efs.** { *; }
-keepclassmembers class * {
public <init> (org.json.JSONObject);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}The SDK needs to reference the resource file of the imported project, and obtains the resource reference file R.java through the reflection mechanism. However, when developers use obfuscation /optimization tools such as proguard to process the apk, proguard may delete R.java. If this problem occurs, please add the following configuration:
-keep public class [your app package name]. R$*{
public static final int *;
}