How do I use the location service on the HMS mobile phone?Specifically, which dependencies should be added?
How do I use the location service on the HMS mobile phone?Specifically, which dependencies should be added?
You need to add necessary Maven repository in project level build gradle file. After that you should add location dependencies in app level build.gradle file.
Project level build.gradle:
buildscript {
ext.kotlin_version = '1.3.61'
repositories {
google()
maven { url 'http://developer.huawei.com/repo/' } // HUAWEI Maven repository
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.huawei.agconnect:agcp:1.3.1.300'
}
}
allprojects {
repositories {
google()
maven { url 'http://developer.huawei.com/repo/' }
jcenter()
}
}
App level build.gradle file:
dependencies {
implementation 'com.huawei.hms:location:4.0.3.301'
}
apply plugin: 'com.huawei.agconnect'
I suggest you put Huawei's maven repository at the end line and use https,such as
buildscript {
repositories {
google()
jcenter()
maven { url 'https://developer.huawei.com/repo/' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.huawei.agconnect:agcp:1.3.1.300'
}
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://developer.huawei.com/repo/' }
}
}
the doc in the huawei website: https://developer.huawei.com/consumer/en/doc/development/HMS-Guides/location-preparation#h2-1580888386039-0
you need to add the following dependencies to use location services:
dependencies {
implementation 'com.huawei.hms:location:{version}'
}
Note: Replace {version} with the actual SDK version number, for example: implementation'com.huawei.hms:location:4.0.2.300'. If you also integrate other HMS services, it is recommended that you use the same version of the HMS SDK.