Reputation: 880
I am testing the map kit from Huawei.
The app has been created in App Gallery Connect and I did all the steps. Other HMS services working just right. All my dependencies are right.
So, I use a view to represent the map.
The onMapReady
is called, view loads, I can interact with the map, add pins, find my location, etc.
But I cant see the map, only blank tiles.
I dont get an error, onMapReady
is called just fine.
Also i have tried the demo from Huawei's Github, the result is the same. I have tried with fragment too, same result.
My mapView
<com.huawei.hms.maps.MapView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent"
map:cameraTargetLat="48.893478"
map:cameraTargetLng="2.334595"
map:cameraZoom="8.5"/>
My onCreate
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_huawei_map_test);
Log.d(TAG, "yo: ");
if (!hasPermissions(this, RUNTIME_PERMISSIONS)) {
ActivityCompat.requestPermissions(this, RUNTIME_PERMISSIONS, 100);
}
mMapView = findViewById(R.id.mapView);
Bundle mapViewBundle = null;
if (savedInstanceState != null) {
mapViewBundle = savedInstanceState.getBundle(MAPVIEW_BUNDLE_KEY);
}
MapsInitializer.setApiKey("");//my key
mMapView.getMapAsync(this);
mMapView.onCreate(mapViewBundle);
My onMapReady
@Override
public void onMapReady(HuaweiMap map) {
//get map instance in a callback method
Log.d(TAG, "onMapReady: ");
hMap = map;
//hMap.setMapType(HuaweiMap.MAP_TYPE_TERRAIN);
hMap.setMyLocationEnabled(true);
hMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(48.893478, 2.334595), 10));
Marker mMarker = hMap.addMarker(new MarkerOptions().position(new LatLng(48.893478, 2.334595)));
mMarker.showInfoWindow();
}
The result:
Upvotes: 7
Views: 2065
Reputation: 11
Try editing your API_KEY
in the String
API_KEY
in ~/utils/MapUtils.java
(in case you tried the Sample Code from Huawei Codelabs (Github))
or
Try directly adding your API_KEY
in MapsInitializer.setApiKey("Your_API_KEY_Here")
in your entrance class (like MyActivity
or MainActivity
).
If those above doesn't help, check the places where API_KEY
has to be updated / used. In my case, that caused the problem.
Upvotes: 0
Reputation: 217
Thanks for your very detailed question. At first it looked like this already discussed problem but you did not receive any errors.
A common undetected error is that you did not sign your app properly. Try to clone the official codelab repository and compile the code from there. You need to sign your app with your own key and provide the corresponding SHA fingerprint on the AGC console.
For reference check out this codelab on how to create a signing certificate.
I've tried the repository I linked above, changed the package name, swaped the App ID, filled in the API Key and added the agconnect json file.
On the AGC console I put in the right SHA fingerprint but signed my app with the wrong key. After rebuilding I was wondering why your error was still occurring. It must have been because the app could not be updated with a different signature which makes sense.
Try uninstalling the app and install a newly signed one again. Hard to tell if that'll fix it for you too but if not it would be nice to have a complete stack trace to trouble shoot.
Upvotes: 2