android - 华为 map 不加载瓷砖

标签 android android-studio huawei-mobile-services huawei-developers huawei-map-kit

我已按照文档 herehere (这很简单),但 map View 不加载任何图 block 。
我使用HMS Toolkit,配置向导成功。我还设置了我的 api key ,在我的应用程序类和我的 Activity 类 onCreate 中都使用了这一行。
MapsInitializer.setApiKey(HUAWEI_API_KEY);
以下是设备信息和 SDK 版本:

  • 手机型号:华为 Y7 Prime 2018
  • EMUI版本:8.0.0
  • HMS核心版本:6.1.0.305
  • map SDK版本:com.huawei.hms:maps:6.0.0.301

  • 这是屏幕:
    enter image description here
    相关错误日志:

    E/HmsMapKit_MapView_151: createDelegate: creator == null

    E/HmsMapKit_GrsClient_24: GRS returns empty.

    E/HmsMapKit_ErrorTraceLogPusher_4: cache error trace log : ErrorTraceLogDTO{ scenario = GET_GRS_URL_FAILED', message='GRS returns empty, service name is com.huawei.hms.map.'}

    E/HmsMapKit_ErrorTraceLogPusher_12: eventId is null or empty.

    E/HmsMapKit_AuthenticateClient_27: Exception occur com.huawei.hms.maps.foundation.client.c

    E/HmsMapKit_ErrorTraceLogPusher_4: cache error trace log : ErrorTraceLogDTO{ scenario = ACCESS_SERVICE_ERROR', message='060001 : NETWORK_ERROR'}

    E/HmsMapKit_AuthenticateCache_0: authenticate error, throw RetryException.

    E/HmsMapKit_CopyrightDelegate_27: get copyright statement html data failed: htmlData = null

    E/HmsMapKit_TileCache_38: startUrlRequest Identity fail, do not has permission get tile. authResult :060011


    PS:我与 this demo 有完全相同的问题.

    最佳答案

    首先你可以引用this Docs看看是否有错误代码。
    官方demo也运行不正确。所以问题很可能是由签名或 API key 问题引起的。
    请检查如下:

  • 检查AppGallery Connect中是否启用了Map Kit API。如果没有,启用它,下载.json文件替换代码中已有的,然后检查SHA256指纹是否正确。
  • 在 Android 的 Map SDK 5.0.0.300 或更高版本中,您必须在初始化 map 之前设置 API key 。

  • (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);
    
    有关此问题的不同原因的详细信息,您还可以引用此 answer .

    关于android - 华为 map 不加载瓷砖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69072718/

    相关文章:

    android - SetPage(Xamarin.Forms.Page)' 已过时错误 - Android

    android - 如何下拉刷新 ListView 而不重复它的项目

    android - 多列 ListView 显示零而不是数据库值

    huawei-mobile-services - 是不是所有实现了huawei iap的应用包名都要带.huawei后缀?

    android - Eclipse/Android : can't install Google APIs targets

    android - 在 Cygwin 中使用 repo 下载 Android 源码

    java - android.view.ContextThemeWrapper 无法转换为 android.app.Activity

    android - 在xml编辑器中切换字符串资源的引用和值预览

    huawei-mobile-services - HMS Ads Kit - 无法解析 com.huawei.hms :ads-lite:13. 4.29.303

    android - 是否可以从 Android 上的 TOF(飞行时间)传感器读取数据?