4

遵循华为设置文档https://developer.huawei.com/consumer/en/doc/development/HMS-Plugin-Guides-V1/preparedevenv-0000001050032222-V1后,地图仍然无法在我们的应用程序上呈现。它只是显示空白在模拟器和真实设备上都没有任何错误显示的屏幕

如何让它发挥作用?为了您的信息,我已经做了:

  • 启用地图套件 api
  • 添加agconnect-services.json在我的里面android/app

来自 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:


4

1 回答 1

3

此问题可能有不同的原因。请检查如下:

  • 检查AppGallery Connect中是否启用了Map Kit API。如果没有,启用它,下载.json文件替换代码中已有的,然后检查SHA256指纹是否正确。

  • 在 Android 的 Map SDK 5.0.0.300 或更高版本中,您必须在初始化地图之前设置 API 密钥。

(1) 在你项目的入口类中设置API key。

   // 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 key。

    @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:没有任何数据的空地图。

你也可以参考这个答案

于 2021-11-03T01:03:58.230 回答