Sample integration of Huawei Mobile Services (HMS, Map Kit) for existing app with Google Mobile Services. This repo show how to create HMS flavor of your app and split GPS/HMS imports when using Android Architecture components (LiveData and ModelView).
This sample show Map (HMS or GPS) and when button Randomize
is pressed generates 1000 random points with custom icons on map.
To show how to integrate both HMS and GPS services side-by-side. It is done using 2 flavors, to visualize how many object that you wouldn't expect are provider-dependent (ex. LatLng
or BitmapDescriptor
just to name few in such simple use case).
- For HMS flavor:
- Huawei device (with HMS), otherwise map will result in error. But it will build fine.
agconnect-services.json
(/app
level) that you can obtain fromHuawei Developer Console
link on how to do it.
- For GPS flavor:
- Obtain Google Map key and put it inside
mapKeysFile.properties
on root level ex. googleMapsKey="YOUR_API_KEY_HERE". - Obtain
google-services.json
(/app
level) that you can obtain fromGoogle Firebase Console
. - Device with GPS.
- Obtain Google Map key and put it inside
If you got error when map is showing:
getRemoteContext: DynamicModule load failedcom.huawei.hms.feature.dynamic.DynamicModule$LoadingException: Query huawei_module_maps unavailable, errorCode:2
getRemoteContext: DynamicModule load failedcom.huawei.hms.feature.dynamic.DynamicModule$LoadingException: Query huawei_module_maps unavailable, errorCode:4
getRemoteMapContext failed
HmsMapKit_HmsUtil_88: Hms is :0
That mean device is not Huawei and is not eligible for HMS Map Kit. If code is other number - check HMS documentation here.
I'm open to pull requests. This is just sample on probably most used Google and Huawei SDK to visualize what is needed and how it affects your code (assuming basic architecture) and a good starting point.
- Fetching current location
- Repository for providing mock data
- Automatic testing