Android SDK Plugin Description
|
Collect
1. Description
The Sensosrdata Android Tracking SDK Plugin has made significant functional updates since version v4.0.0-beta to adapt to AGP 8.0+ (Android Gradle Plugin), including:
- Compatibility of AGP 8.0+ Instrumentation API and Transform API;
- Support for Gradle Plugins DSL integration;
- Optimized plugin configuration, please refer to the Plugin Configuration section for specific details.
2. Gradle Plugins DSL Integration
2.1. Add Maven Repository
Add Maven Repository in settings.gradle file:
pluginManagement { repositories { gradlePluginPortal() google() mavenCentral() //Maven 仓库 //... } } dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google() mavenCentral() //Maven 仓库 //... } } ...
2.2. Declare plugin path
Add Sensosrdata plugin declaration in project/build.gradle:
plugins { id 'com.android.application' version '7.3.1' apply false //demo used id 'com.android.library' version '7.3.1' apply false //demo used id 'org.jetbrains.kotlin.android' version '1.7.20' apply false id 'org.jetbrains.kotlin.jvm' version '1.7.20' apply false //... //添加神策插件路径声明,4.0.0-beta 是插件版本号 id 'com.sensorsdata.analytics.android' version "4.0.0-beta" apply false }
2.3. Use the plugin
Use the plugin in app/build.gradle:
plugins { id 'com.android.application' id 'org.jetbrains.kotlin.android' //... //使用神策插件 id 'com.sensorsdata.analytics.android' }
3. Common Plugin Configuration
3.1. Changes in Plugin 4.0.0+
In order to simplify plugin configuration and adapt to AGP 8.0+, the following plugin configurations have been removed since Plugin 4.0.0+:
- disablePlugin
- disableMultiThreadBuild
- disableIncrementalBuild
- disableJar
- disableTrackPush
- disableCheckSDK
- autoHandleWebView
Configuration | Reason for deletion and replacement |
---|---|
| Redundant configuration. Can be replaced by not using plugins. |
| Cannot be applied in AGP 8.0+. |
| Cannot be applied in AGP 8.0+. |
| Cannot be applied in AGP 8.0+. |
| Please use disableModules instead. |
| Please use disableModules instead. |
| Please use disableModules instead. |
Attention
- If the project involves the above configuration, you can choose not to upgrade to Plugin 4.0.0+.
- If the project uses AGP 8.0+, an alternative method needs to be selected.
3.2. debug
The default value is false.
Represents whether to enable the debug mode.
If the debug mode is enabled, detailed log information will be printed during the compilation.
sensorsAnalytics { debug = true }
3.3. exclude
Blacklist, you can use exclude to specify which class or package not to process.
Configuration example:
sensorsAnalytics { exclude = ['a.b.c', 'a.b.c.A'] }
Don't process a specific class or all classes under a package.
3.4. Enable UC Browser integration
Used for annotation insertion in the UC Browser kernel.
sensorsAnalytics { addUCJavaScriptInterface = true }
3.5. sensorsAnalytics.isHookOnMethodEnter
Whether to insert code when entering a method, the default value is false. This configuration only applies to plugin version 3.1.9 and above.
If you need to configure it, add the following configuration to the gradle.properties in the project:
sensorsAnalytics.isHookOnMethodEnter = true
3.6. disableModules
Used to indicate the disabled modules, which will not be instrumented. This configuration only applies to plugin version 4.0.0+, and currently supports the following configurations:
- AUTOTRACK
- PUSH
- WEB_VIEW
Especially when using the modularized dependency approach to integrate SensorsData SDK, be sure to disable certain modules, such as:
sensorsAnalytics { disableModules = ['PUSH'] }
The above configuration indicates that no instrumentation will be applied to the "push" module.
Note: The content of this document is a technical document that provides details on how to use the Sensors product and does not include sales terms; the specific content of enterprise procurement products and technical services shall be subject to the commercial procurement contract.