Home > front end >  Huawei Map Kit React Native not render the map
Huawei Map Kit React Native not render the map

Time:11-03

After following huawei setup docs https://developer.huawei.com/consumer/en/doc/development/HMS-Plugin-Guides-V1/preparedevenv-0000001050032222-V1, maps still not render on our apps.. It just showing blank screen without any error show, on both emulator and real device

How to make it work? For your info, I already did:

  • Enable map kit api
  • Added agconnect-services.json inside my android/app

From logcat

11-03 14:53:54.449 W/dynamic-api_DynamicModule( 9322): 9322-9322|null|com.huawei.hms.maps.internal.HmsUtil|isFallbackPresent|5|Query remote module:huawei_module_maps exception:com.huawei.hms.feature.dynamic.DynamicModule$a: failed to Query remote version.
11-03 14:53:54.455 D/HmsMapKit_HmsUtil_47( 9322): get fallback version failed 
11-03 14:53:54.455 D/HmsMapKit_HmsUtil_65( 9322): get hms apk version  : 0 fallbackVersion : 0
11-03 14:53:54.456 D/HmsMapKit_HmsUtil_44( 9322): isInitialized is: falserepeatFlag is: true
11-03 14:53:54.457 I/HmsMapKit_HmsUtil_169( 9322): hmsVersionStr 5.0.1.300
11-03 14:53:54.457 I/HmsMapKit_HmsUtil_197( 9322): baseVersion 50001300
11-03 14:53:54.463 E/HMSSDK_HMSPackageManager( 9322): Failed to find HMS apk
11-03 14:53:54.466 E/HMSSDK_HMSPackageManager( 9322): Failed to find HMS apk
11-03 14:53:54.466 I/HmsMapKit_AvailableAdapter_39( 9322): HMS is not installed
11-03 14:53:54.467 I/HmsMapKit_HmsUtil_226( 9322): Hms is :1
11-03 14:53:54.469 D/HmsMapKit_HmsUtil_4( 9322): Hms is resolution :
11-03 14:53:54.471 E/HMSSDK_HMSPackageManager( 9322): Failed to find HMS apk


11-03 14:53:54.513 E/ActivityThread( 9322): Failed to find provider info for com.huawei.hms
11-03 14:53:54.514 W/dynamic-api_DynamicModule( 9322): 9322-9322|null|com.huawei.hms.feature.dynamic.DynamicModule|load|25|Get hms loader info failed:failed to get :huawei_module_dynamicloader info.
11-03 14:53:54.517 W/dynamic-api_AssetLoadManager( 9322): 9322-9322||a.a.a.b.a.a|a|6|No module apk in asset path.
11-03 14:53:54.518 W/dynamic-api_DynamicModule( 9322): 9322-9322|null|com.huawei.hms.feature.dynamic.DynamicModule|load|25|No available dynamic loader in HMS and asset.
11-03 14:53:54.518 E/HmsMapKit_MapCreator_49( 9322): Loading mapRoute dynamically failed, exception is com.huawei.hms.feature.dynamic.DynamicModule$LoadingException: Cannot find a valid dynamicLoader in HMS and local.
11-03 14:53:54.519 E/HmsMapKit_MapCreator_28( 9322): getRemoteMapContext failed
11-03 14:53:54.521 D/HmsMapKit_MapView_4( 9322): getMapAsync:


CodePudding user response:

There may be different causes of this problem. Please check as follows:

  • Check whether the Map Kit API is enabled in AppGallery Connect. If not, enable it, download the .json file to replace the existing one in the code, and then check whether the SHA256 fingerprint is correct.

  • In the Map SDK 5.0.0.300 or later for Android, you must set an API key before initializing the map.

(1) Set the API key in the entrance class of your project.

   // In the entrance class (inherited from android.app.Application) of the app,
    // call the setApiKey method in the overridden onCreate() method. 
    public class MyApp extends Application {
        @Override
        public void onCreate() {
            super.onCreate();
           // Set the API key.
            MapsInitializer.setApiKey("Your API Key");
        }
    }

(2) Set the API key in Fragment or MapView.

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        Log.i(TAG, "onCreate: ");
        super.onCreate(savedInstanceState);
        // Set the API key before calling setContentView.
        MapsInitializer.setApiKey("Your API Key");
        setContentView(R.layout.basic_demo);
  • Currently, HuaweiMap supports two types of maps. Determine the type that you are using.

    MAP_TYPE_NORMAL: standard map, which shows roads, artificial structures, and natural features such as rivers.

    MAP_TYPE_NONE: empty map without any data.

You could also refer to this answer.

  • Related