Jagni Yugnu
Jagni Yugnu

Reputation: 11

HMS Map Kit problem - Huawei Map doesn't load

What could be the reason why the map is not being loaded even though I perform all the implementations?

Upvotes: 1

Views: 4686

Answers (5)

JerabekJakub
JerabekJakub

Reputation: 5340

In my case it was because of mismatch SupportMapFragment and MapFragment used in layout and code.

Layout:

<fragment xmlns:map="http://schemas.android.com/apk/res-auto"
            android:id="@+id/mapFragment"
            class="com.huawei.hms.maps.SupportMapFragment" />

Code:

val mapFragment = childFragmentManager.findFragmentById(R.id.mapFragment) as SupportMapFragment?

Upvotes: 0

EpicPandaForce
EpicPandaForce

Reputation: 81568

1.) make sure MapKit is enabled in AppConnect

2.) make sure your agconnect-services.json is properly loaded for your selected flavor

3.) make sure that the json package name matches your app's applicationId

4.) make sure the SHA-256 certificate fingerprint provided is the same cert as what you use to sign the application

5.) make sure you actually sign the application

And so far this is the same as the existing answer, so here is one more thing to note:

6.) make sure the certificate you use is SHA256withRSA (you see this when you can check SHA1, SHA256 and so on)

7.) also make sure that while you have the agconnect-services.json, you ALSO set the keystore signature on the API Services -> Credentials page.

Upvotes: 4

Zinna
Zinna

Reputation: 2035

The most common reason for the map not being loaded is that the client did not send the right credential to the map server and the map server did not return the response with the map data. Check to see if the app has the MAP API enabled in the developer console, signature fingerprint matches, and the app has the correct downloaded agconnect-services.json in the app directory. You could follow the Huawei Map Kit tutorial codelabs。 Make sure don’t miss any steps and compare your code and the sample code to see if there is any difference.

Upvotes: 0

Nithin
Nithin

Reputation: 972

Make sure all these

in app-level build.gradle

dependencies { 
implementation 'com.huawei.hms:maps:4.0.1.302'

}

In Manifest

<uses-permission android:name="android.permission.INTERNET"/> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> 
<uses-permission 
android:name="com.huawei.appmarket.service.commondata.permission.GET_COMMON_DATA"/>

//To obtain current device location
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> 
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

provide real time permission

private void requestPermission() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
    Log.i(TAG, "sdk >= 23 M");
    if (ActivityCompat.checkSelfPermission(this,
            Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
            || ActivityCompat.checkSelfPermission(this,
            Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        String[] strings =
                {Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION};
        ActivityCompat.requestPermissions(this, strings, 1);
    }
}
}

After this Load MapView in the onCreate() or onCreateView() method and call getMapAsync() to register the callback.

Hope this will work.

Upvotes: 3

Mahmut Can Sevin
Mahmut Can Sevin

Reputation: 96

There are more than one reason. I will mention some of reasons that cause this issue:

  1. Make sure the MAP kit is enabled in you app from Huawei Developer.

  2. Make sure you add the dependency for Map Kit in Build.Gradle app.

  3. Make sure the SHA-256 certificate fingerprint that you entered in develeper is the same in the app.

  4. Make sure that you entered the signingConfigs in the build.gradle app.

Upvotes: 3

Related Questions