If you are using Android Studio, you can integrate the HMS Core SDK via the Maven repository. Before you start developing an app, integrate the HMS Core SDK into your Android Studio project.


The procedure for configuring the Maven repository address in Android Studio is different for Gradle plugin earlier than 7.0, Gradle plugin 7.0, and Gradle plugin 7.1 or later. Click a relevant link below to find the configuration procedure for the specific Gradle plugin version.
The Maven repository address cannot be accessed from a browser. It can only be configured in the IDE. If there are multiple Maven repositories, add the Maven repository address of Huawei as the last one.

buildscript {
repositories {
google()
jcenter()
// Configure the Maven repository address for the HMS Core SDK.
maven {url 'https://developer.huawei.com/repo/'}
}
dependencies {
...
// Add the AppGallery Connect plugin configuration. Please refer to AppGallery Connect Plugin Dependency to select a proper plugin version.
classpath 'com.huawei.agconnect:agcp:1.6.0.300'
}
}
allprojects {
repositories {
google()
jcenter()
// Configure the Maven repository address for the HMS Core SDK.
maven {url 'https://developer.huawei.com/repo/'}
}
} 
buildscript {
repositories {
google()
jcenter()
// Configure the Maven repository address for the HMS Core SDK.
maven {url 'https://developer.huawei.com/repo/'}
}
dependencies {
...
// Add the Android Gradle plugin configuration. You need to replace {version} with the actual Gradle plugin version, for example, 7.0.1.
classpath 'com.android.tools.build:gradle:{version}'
// Add the AppGallery Connect plugin configuration. Please refer to AppGallery Connect Plugin Dependency to select a proper plugin version.
classpath 'com.huawei.agconnect:agcp:1.6.0.300'
}
}dependencyResolutionManagement {
...
repositories {
google()
jcenter()
// Configure the Maven repository address for the HMS Core SDK.
maven {url 'https://developer.huawei.com/repo/'}
}
}
buildscript {
dependencies {
...
// Add the Android Gradle plugin configuration. You need to replace {version} with the actual Gradle plugin version, for example, 7.1.1.
classpath 'com.android.tools.build:gradle:{version}'
// Add the AppGallery Connect plugin configuration. Please refer to AppGallery Connect Plugin Dependency to select a proper plugin version.
classpath 'com.huawei.agconnect:agcp:1.6.0.300'
}
}
plugins {
...
} pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
// Configure the Maven repository address for the HMS Core SDK.
maven { url 'https://developer.huawei.com/repo/' }
}
}
dependencyResolutionManagement {
...
repositories {
google()
mavenCentral()
// Configure the Maven repository address for the HMS Core SDK.
maven { url 'https://developer.huawei.com/repo/' }
}
}
apply plugin: 'com.huawei.agconnect'
plugins {
id 'com.android.application'
// Add the following configuration:
id 'com.huawei.agconnect'
}implementation 'com.huawei.hms:hianalytics:{version}' implementation 'com.huawei.hms:dtm-api:{version}'
Replace {version} with the actual SDK version number. For details about the Analytics Kit version number, please refer to version-change-history. For details about the DTM version number, please refer to Version Change History.
Example: implementation 'com.huawei.hms:hianalytics:6.12.0.301' and implementation 'com.huawei.hms:dtm-api:6.6.0.308'.
After integrating the DTM plugin, you can dynamically inject event tracking code to the target class during app build, therefore improving the app runtime performance.
If the version in com.huawei.hms:dtm-api:version is 5.2.0.300 or later, you are advised to integrate the DTM plugin.
The plugin is available only for Android Studio projects.
After integrating the plugin, you can skip 2 in Adding Visual Events for a Fragment.
buildscript {
repositories {
google()
jcenter()
// Configure the Maven repository address.
maven {url 'https://developer.huawei.com/repo/'}
}
dependencies {
...
// Add the DTM plugin configuration.
classpath 'com.huawei.hms:dtm-plugin:6.1.0.300'}
}
allprojects {
repositories {
google()
jcenter()
// Configure the Maven repository address.
maven {url 'https://developer.huawei.com/repo/'}
}
} apply plugin: 'com.huawei.hms.dtm.plugin'
plugins {
id 'com.android.application'
// Add the plugin configuration.
id 'com.huawei.hms.dtm.plugin'
}android { }
// Configure the following information.
dtmConfig{
// Specify whether to record DTM plugin compilation logs. true: yes; false: no.
debug = true
}