Huawei Map Kit React Native 不渲染地图
Huawei Map Kit React Native not render the map
按照华为设置文档 https://developer.huawei.com/consumer/en/doc/development/HMS-Plugin-Guides-V1/preparedevenv-0000001050032222-V1 后,地图仍然无法在我们的应用程序上呈现。
它只是在模拟器和真实设备上显示空白屏幕,没有任何错误显示
如何让它发挥作用?
为了您的信息,我已经这样做了:
- 启用地图工具包api
- 在我的
android/app
中添加了 agconnect-services.json
来自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:
这个问题可能有不同的原因。请检查如下:
检查是否在AppGallery Connect中启用了Map Kit API。如果没有,启用它,下载.json文件替换代码中已有的,然后检查SHA256指纹是否正确。
在 Android 的 Map SDK 5.0.0.300 或更高版本中,您必须在初始化地图之前设置一个 API 键。
(1) 在项目入口class设置API键
// 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) 在Fragment或MapView中设置API键
@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);
目前HuaweiMap支持两种地图。确定您使用的类型。
MAP_TYPE_NORMAL:标准地图,显示道路、人工建筑物和河流等自然景观。
MAP_TYPE_NONE: 没有任何数据的空地图。
您也可以参考。
按照华为设置文档 https://developer.huawei.com/consumer/en/doc/development/HMS-Plugin-Guides-V1/preparedevenv-0000001050032222-V1 后,地图仍然无法在我们的应用程序上呈现。 它只是在模拟器和真实设备上显示空白屏幕,没有任何错误显示
如何让它发挥作用? 为了您的信息,我已经这样做了:
- 启用地图工具包api
- 在我的
android/app
中添加了
agconnect-services.json
来自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:
这个问题可能有不同的原因。请检查如下:
检查是否在AppGallery Connect中启用了Map Kit API。如果没有,启用它,下载.json文件替换代码中已有的,然后检查SHA256指纹是否正确。
在 Android 的 Map SDK 5.0.0.300 或更高版本中,您必须在初始化地图之前设置一个 API 键。
(1) 在项目入口class设置API键
// 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) 在Fragment或MapView中设置API键
@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);
目前HuaweiMap支持两种地图。确定您使用的类型。
MAP_TYPE_NORMAL:标准地图,显示道路、人工建筑物和河流等自然景观。
MAP_TYPE_NONE: 没有任何数据的空地图。
您也可以参考