Huawei Map Kit throws Network Error (Code 060001) when calling it from Android app

633 Views Asked by At

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!

2

There are 2 best solutions below

1
On BEST ANSWER

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.

7
On

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.