Android Application Integration¶
Collect metrics from Android applications to analyze application performance visually.
Reading Path¶
- First-time integration: start with Choose an Access Method; for manual integration, see Quick Start
- Full integration: continue reading this document
- Parameter details: see SDK Initialization, RUM Configuration, Log Configuration, Trace Configuration
- Advanced capabilities: see the dedicated pages in the "Advanced Scenarios" group
- Troubleshooting: see Troubleshooting
Prerequisites¶
Note
If the RUM Headless service is enabled, the prerequisites are configured automatically, and you can integrate the application directly.
For local environment deployment, complete the following data receiver configuration; with the public DataWay, you do not need to deploy DataKit yourself.
- Install DataKit;
- Configure the RUM collector;
- Configure DataKit to be publicly accessible and install the IP geolocation database.
Application Integration¶
- Go to RUM > Create Application > Android;
- Enter the application name;
- Enter the application ID;
- In "Access Method", select Agent auto-integration or manual integration, then complete the "Integration Configuration".
Choose an Access Method¶
On the application configuration page, select "Agent Auto-Integration" or "Manual Integration", then complete the "Integration Configuration". For existing applications, go directly to the configuration page to continue the integration.
| Access method | Use Cases | Entry point |
|---|---|---|
| Agent auto-integration | Want a coding assistant to analyze the project and complete SDK integration | Copy the prompt generated by the console and give it to the coding assistant in the application code repository |
| Manual integration | Want to install the SDK and configure parameters yourself | Confirm the data reporting method, then follow this document and Quick Start to complete the configuration |
Agent Auto-Integration¶
- On the configuration page of the current application, select "Agent Auto-Integration".
- Copy the complete prompt from "Integration Configuration", and make sure it uses the integration information of the current application.
- Open the coding assistant in the application code repository, paste the prompt, and let the Agent analyze the project and complete the SDK configuration according to the integration guide.
- Build and run the application, trigger operations such as page views, and confirm in the Explorer of the current application that data is received.
If the page indicates that the personal API Key or temporary authorization code is not ready, complete it as prompted and then copy the prompt again.
Manual Integration¶
On the application configuration page, select "Manual Integration", and confirm the data reporting method:
- Public DataWay: receives RUM data directly; no DataKit collector is required.
- Local environment deployment: receives RUM data after the prerequisites are met.
Follow Installation and Quick Start below to complete SDK installation, initialization, and verification. If an SDK configuration already exists, check and reuse it first to avoid duplicate initialization.
Installation¶
Source code: https://github.com/GuanceCloud/datakit-android
Demo: https://github.com/GuanceDemo/guance-app-demo
Gradle Configuration¶
Add the Plugin¶
- Add the remote repository URL for the
SDKin thebuild.gradlefile in the project root directory
//build.gradle
buildscript {
//...
repositories {
//...
//Add the remote repository URL for the Plugin
maven {
url 'https://mvnrepo.guance.com/repository/maven-releases'
}
}
dependencies {
//...
//Add the Plugin; requires AGP 7.4.2 or later and Gradle 7.2.0 or later
classpath 'com.cloudcare.ft.mobile.sdk.tracker.plugin:ft-plugin:[latest_version]'
// For AGP versions below 7.4.2, use ft-plugin-legacy
//classpath 'com.cloudcare.ft.mobile.sdk.tracker.plugin:ft-plugin-legacy:[latest_version]'
}
}
//setting.gradle
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
//Add the remote repository URL for the Plugin
maven {
url('https://mvnrepo.guance.com/repository/maven-releases')
}
}
}
//build.gradle
plugins{
//Add the Plugin; requires AGP 7.4.2 or later and Gradle 7.2.0 or later
id 'com.cloudcare.ft.mobile.sdk.tracker.plugin' version '[latest_version]' apply false
// For AGP versions below 7.4.2, use ft-plugin-legacy
//id 'com.cloudcare.ft.mobile.sdk.tracker.plugin.legacy' version '[latest_version]' apply false
}
- Apply the
Pluginin theapp/build.gradlefile of the main module
//Apply the plugin in app/build.gradle. Missing configuration affects the following automatic collection features.
//
// 1. RUM: app launch, OkHttp requests, on-demand HTTP/HTTPS URLConnection requests, WebView activity Activity/Fragment navigation, click events
// 2. Log: Console Logcat
apply plugin: 'ft-plugin' //If you use ft-plugin-legacy, use this configuration as well
//Optional: configure plugin parameters as needed
FTExt {
//showLog = true
//asmVersion='asm7'
//ignorePackages=['com.ft','com/ft']
//knownWebViewClasses = ['com.your.CustomWebView']
}
All plugin parameters are optional. In most cases, only apply plugin: 'ft-plugin' is required; add FTExt configuration only when debugging plugin behavior, controlling the instrumentation scope, or manually supplementing WebView identification.
| Parameter name | Type | Default value | Description | Use Cases |
|---|---|---|---|---|
| showLog | Boolean | false |
Whether to output build logs of ft-plugin. |
Enable when debugging plugin execution or troubleshooting whether instrumentation takes effect. |
| asmVersion | String | asm9 |
Specifies the ASM version used by the plugin; valid values are asm7 to asm9. |
Adjust when there are compatibility requirements with other bytecode processing plugins in the project. |
| ignorePackages | String[] | Empty | Configures package paths that are not instrumented by ASM; path separators can be . or /. |
Use when you need to skip certain business packages, third-party packages, or code that conflicts with other plugins. |
| instrumentHttpURLConnection | Boolean | true |
Whether to instrument the return values of URL.openConnection() / openConnection(Proxy); supported in ft-plugin >= 1.3.9-alpha01 and requires ft-sdk >= 1.7.6-alpha03. |
Set to false when URLConnection instrumentation needs to be disabled; actual collection also requires two RUM switches to be enabled. See URLConnection Auto-Collection for details. |
| knownWebViewClasses | String[] | Empty | Manually declares custom classes to be identified as WebView. | Use when the custom WebView inheritance hierarchy is complex and automatic identification does not take effect. |
knownWebViewClassesonly needs to be configured when automatic identification fails. For troubleshooting methods, see Custom WebView Auto-Collection Not Working.
Add the SDK¶
- Add the remote repository URL for the
SDKin thebuild.gradlefile in the project root directory
- Add the
SDKdependency in theapp/build.gradlefile of the main module
//app/build.gradle
dependencies {
//Add the SDK dependency
implementation 'com.cloudcare.ft.mobile.sdk.tracker.agent:ft-sdk:[latest_version]'
//Dependency for capturing native layer crash information; must be used with ft-sdk and cannot be used alone
implementation 'com.cloudcare.ft.mobile.sdk.tracker.agent:ft-native:[latest_version]'
// JSON serialization
implementation 'com.google.code.gson:gson:2.8.+'
//Optional; add when using OkHttp automatic network request collection and automatic distributed tracing; minimum compatible version is 3.12.+
implementation 'com.squareup.okhttp3:okhttp:4.+'
}
For the latest versions, see the
ft-sdk,ft-plugin, andft-nativeversion names above.
Application Configuration¶
The best place to initialize the SDK is in the onCreate method of Application. If your application has not yet created an Application, create one and declare it in AndroidManifest.xml; see here for an example.
R8 / ProGuard Obfuscation Configuration¶
If you are using a version earlier than ft-sdk 1.6.15 and need to set minifyEnabled = true in android.buildTypes, enable the following configuration:
-dontwarn com.ft.sdk.**
### ft-sdk library
-keep class com.ft.sdk.**{*;}
### ft-native library
-keep class ftnative.*{*;}
### Prevent class names in action_name from being obfuscated when obtaining Actions ###
-keepnames class * extends android.view.View
-keepnames class * extends android.view.MenuItem
Initialization Notes¶
For a minimal initialization example, see Quick Start.
For the complete description of FTSDKConfig parameters, see SDK Initialization.
Detailed Configuration¶
Advanced Scenarios¶
- Custom Tags
- Custom Collection Rules
- Data Masking
- WebView Monitoring
- Visitor ID
- Dynamic Configuration and Dynamic Update URL
- Symbol File Upload
- Privacy and Permissions
- Content Provider Settings
- Manual Compatible Integration
Ignoring Plugin AOP¶
Add @IgnoreAOP to methods overridden by Plugin AOP to skip ASM insertion. To ignore in batches, use ignorePackages in ft-plugin FTExt.
FAQ¶
Add Local Variables to Avoid Conflicting Fields¶
To avoid conflicts between custom fields and SDK data, add a project abbreviation prefix to tag names, for example, custom_tag_name. You can look up the key values used in the project in the source code. If a global variable in the SDK has the same name as one in RUM or Log, the RUM or Log variable overrides the SDK global variable.
SDK Compatibility¶
Comply with App Marketplace Privacy Reviews¶
For details, see Privacy and Permissions.
Third-Party Frameworks¶
flutter, react-native, uni-app, and unity can adopt a delayed initialization approach similar to native Android above to comply with app marketplace privacy reviews.
Jetpack Compose Support¶
Automatic collection of pages generated by compose components is not currently supported. However, you can track click events and page navigation events through the custom Action and View interfaces; see here for an example.