I tried following the instructions in the official codelab Here's a link to the corresponding source code: https://github.com/huaweicodelabs/MapKit
What I did:
- Modified the packagename(AppGallery Connect portal doesn't allow apps with package-names that have already been claimed by someone else for their app)
- Created a keystore file for signing (Used the Build->'Generate signed APK' flow to create it)
- updated the attributes inside
signingConfigs{release{...}}
section with:
storeFile file("/Users/myuser/mydir/mykeystorexyz") // no .jks extension as it's unimportant
storePassword "mypass123"
keyAlias "mykeystorexyz" //I had kept the name and alias of the file to be same
keyPassword "mypass123"
v2SigningEnabled true
- Created a Project and App on Huawei Appgallery Connect with the new packagename. Also Enabled the Mapkit API from the user interface.
- Downloaded
agconnect-services.json
inside theapp
directory of the project - Copied the long API key inside
agconnect-services.json
and passed it as a parameter toMapsInitializer.setApiKey()
insideMainActivity.java
. - Used the
keytool -list -v -keystore /Users/myuser/mydir/mykeystorexyz
command to get keystore information and copied the SHA256 fingerprint. Pasted this fingerprint inside the App Information section on the 'AppGallery Connect' portal. - I then installed and ran the debug APK on my Pixel 5A(Android 12) device with latest version of HMS Core installed(I tried version
6.6.0.331
from APKMirror). Map did not get displayed and I could see a very high number of errors on Logcat. Hence I decided to increment library versions and started usingcom.huawei.hms:maps:6.5.1.300
andcom.huawei.agconnect:agcp:1.6.0.300
. This greatly reduced the number of runtime errors but the map would still not get displayed and I would see the following error message inside Logcat:
E/HmsMapKit_MapView_15: MapsInitializer is not initialized.
E/HmsMapKit_MapView_8: MapsInitializer is not initialized.
I'm not sure about what's going wrong in this case. Why is the MapsInitializer
not being initialized ?
Is there a mismatch between the versions of the core HMS SDK and the MapKit SDK I'm using ?
I tried running the APK on a Huawei Cloud Device but got the same results.
Can anybody point any possible causes of this error ? I wasn't expecting to run into any issues since I made minimal changes to the source code of the official code lab.
Edit:
I went through the documentation and realized that MapsInitializer.initialize(this);
needs to be added before the call to MapsInitializer.setApiKey()
for newer versions of HMS Map Kit. This got rid of the MapsInitializer is not initialized
error but the map is still not getting displayed.
Now, whenever I run the app I end up seeing a prompt to update HMS core to the latest version. The update always fails with the following message: Unable to update at the moment. Please try again later (Error 102)
I figured that it may be an issue with my Google Pixel 5A phone running on Android 12 and hence attempted to upload the App's APK to the Mobile Cloud Debugging Console which has Huawei-supported Android devices. I made 2 different attempts. First, I tried uploading the APK using the Appgallery Connect's UI interface and running the APK there - however the same error message would show up (I was able to verify that a version of HMS Core was pre-installed on these devices). I also tried cloud debugging using the HMS Core plugin for Android Studio - but that service seems to be down.