I am implementing Map Kit on my Android app. After following the official documentation on installing the HMS Core SDK, I have:
- Enabled Map Kit, Location Kit and Site Kit on AppGallery Connect.
- Added agconnect-services.json
- Encoded my API key using
URLEncoder
andutf-8
. - Copied my SHA-256 certificate fingerprints for my release version AND debug version (using different keystore entries).
- Asked for location permission.
- 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!