Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
709 views
in Technique[技术] by (71.8m points)

Cannot get com.huawei.hms.location.LocationServices for Huawei Map Kit in android studio

I am currently trying to migrate Google Maps to Huawei map kit in my android project.

It was easy to migrate google maps to Huawei map at first. They are provided all the methods and classes that Google Maps have but now I couldn't get LocationServises class from Huawei that I used in my google maps.

In the documentation they say that Huawei Map kit has com.huawei.hms.location package and LocationServises inside. But why I cannot get it???

The links and libs that I added to gradle below: I refer the Huawei Map Kit documentation

 1. maven {url 'https://developer.huawei.com/repo/'} 

 2. classpath 'com.huawei.agconnect:agcp:1.2.1.301'

 3. maven {url 'https://developer.huawei.com/repo/'} 

 4. implementation 'com.huawei.hms:maps:5.1.0.300'

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can find the location services in the following artifactory

// Huawei implementation "com.huawei.hms:location:4.0.3.301"

And retrieve the location with: FusedLocationProviderClient

Retrieve the last location with the listener

private var fusedLocationProviderClient: FusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(context)

fusedLocationProviderClient.lastLocation.addOnSuccessListener { location -> Log.d("Location", location)
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
...