1

I am implementing Map Kit on my Android app. After following the official documentation on installing the HMS Core SDK, I have:

  1. Enabled Map Kit, Location Kit and Site Kit on AppGallery Connect.
  2. Added agconnect-services.json
  3. Encoded my API key using URLEncoder and utf-8.
  4. Copied my SHA-256 certificate fingerprints for my release version AND debug version (using different keystore entries).
  5. Asked for location permission.
  6. Setting my API key on MapsInitializer before it's loaded.

In summary, my code looks like this:

override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        try {
            API_KEY = URLEncoder.encode(
                getString(R.string.api_key),
                "utf-8"
            )
            MapsInitializer.setApiKey(API_KEY)
        } catch (ignored: UnsupportedEncodingException) {
        }

        binding = ActivityMapBinding.inflate(layoutInflater)
        setContentView(binding.root)
        viewModel = ViewModelProvider(
            this,
            MapViewModel.MyViewModelFactory(application)
        )[MapViewModel::class.java]


        var mapViewBundle: Bundle? = null
        if (savedInstanceState != null) {
            mapViewBundle = savedInstanceState.getBundle(MAPVIEW_BUNDLE_KEY)
        }
        mMapView = binding.mapView
        mMapView.onCreate(mapViewBundle)
        mMapView.getMapAsync(this)
        siteInfo = binding.siteInfo
        siteInfo.visibility = View.GONE
        // ...
}

But all I get when entering the activity is the blue point of my location over a blank map and a Toast saying REQUEST_DENIED.

Checking the logs, there seems not to be an API authentication or signing error, but most likely Petal Maps API being down:

E/HmsMapKit_ErrorTraceLogPusher_4: cache error trace log : ErrorTraceLogDTO{ scenario = ACCESS_SERVICE_ERROR', message='060001 : NETWORK_ERROR'}
com.huawei.hms.maps.foundation.client.mac: *e*v*r*A*d*e*s*f*o* *R* *s*e*p*y*
    at com.huawei.hms.maps.foundation.client.mac$maa.b(Unknown Source:25)

This is disturbing, because there's no sign of this error code in the official Map Kit error codes documentation. Does anyone know what's going on? Thanks in advance!

xvlaze
  • 837
  • 1
  • 10
  • 30

2 Answers2

3

Solved it! Here's my config:

  • HMS Core: latest version as of 14/03/2022 (6.4.0.306)

  • Map Kit: latest version as of 14/03/2022 (implementation 'com.huawei.hms:maps:6.3.1.300')

Main cause: my app signing configuration was missing in my build.gradle file.

Steps to solve it:

  1. Deleted my existing keystore (.jks). DISCLAIMER: you will lose the capacity to update your app if it's released in AppGallery. Please do it as a last resort.

  2. Created a new keystore INSIDE my Android Studio project, under the app directory.

  3. Generated a signed APK for release and obtained the SHA-256 fingerprint.

  4. Replaced my former fingerprint with the new one in AppGallery Connect.

  5. In my map activity, DIDN'T encode my API key (thanks shirley!)

  6. Rebuilt my project.

Complete instructions are here.

xvlaze
  • 837
  • 1
  • 10
  • 30
0

Update

This problem has been fixed in the latest version of the HMS Core. Try to upgrade the HMS Core apk to the latest version which may solve this issue.

Currently, the latest version of the HMS Core is 6.5.0.312.


Thank you for providing the information regarding this issue. We have reported this issue to the R&D team for handling, may i confirm is the HMS Core 6.4.0 installed on your device? You are advised to roll back to HMS Core 6.3 version apk. And we will release a patch package as soon as possible to fix this issue.

zhangxaochen
  • 32,744
  • 15
  • 77
  • 108
  • Hi Shirley, just rolled back but now my app is complaining about the HMS Core version. How can I make it accept the 6.3 version? Gradle? – xvlaze Mar 14 '22 at 07:46
  • hi@xvlaze, before you install HMS Core 6.3 version, you need to uninstall 6.4.0 version frist. You could go to Settings→Apps→Apps→Search "HMS Core"→[Uninstall](https://pbs.twimg.com/media/FNy6ViEacAI_XYr?format=jpg&name=medium), then go to Appgallery search [HMS Core to install it](https://pbs.twimg.com/media/FNy6JSZaAAE2UEK?format=jpg&name=medium). – zhangxaochen Mar 14 '22 at 08:14
  • Hi @shirley, thanks for the quick response. Already did and now I have HMS Core 6.3 on my phone. However, now my app complains I don't have the latest HMS Core version and won't work anymore – xvlaze Mar 14 '22 at 08:31
  • hi@xvlaze, may i confirm what version of the Map Kit you have integrated? Is `com.huawei.hms:maps:6.2.0.301`? If not, I suggest you could try this version instead. – zhangxaochen Mar 14 '22 at 09:34
  • Just downgraded to Map Kit version 6.2.0.301 and nw I can run it using HMS Core 6.3. Now, though, I'm getting: ```ErrorTraceLogDTO{ scenario = ACCESS_SERVICE_ERROR', message='6 : REQUEST_DENIED'}``` – xvlaze Mar 14 '22 at 09:50
  • hi@xvlaze, The character string must be replaced with `MapsInitializer.setApiKey("your api key");`. Otherwise, this error is reported. – zhangxaochen Mar 14 '22 at 12:33
  • Just done it, @shirley, and worked like a charm. That's quite confusing to be honest hahaha – xvlaze Mar 14 '22 at 14:23