繁体   English   中英

谷歌 Map 未在 android 上运行

[英]Google Map not running on android

I'm trying to run google map on android application I have used Debug certificate fingerprint and my package name to get API KEY when I run the application on emulator I got this error

Google Maps Android API: Failed to load map. Error contacting Google servers. This is 
probably an authentication issue (but could be due to network errors).

在下面附加的模拟器中获取银行屏幕时,我确信从我这边来看一切都是正确的

  1. 为 Android 激活地图 SDK

  2. 使用获取调试证书指纹

    keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey - storepass android -keypass android
  3. 将 API 键添加到 res/value/google_maps_api.xml

你能帮忙吗

在此处输入图像描述

我发现了我在 android 应用程序 class 中使用 handleSSLHandShake 的问题,删除它后它工作正常。

    public static void handleSSLHandshake() {
    try {
        TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
            public X509Certificate[] getAcceptedIssuers() {
                return new X509Certificate[0];
            }

            @Override
            public void checkClientTrusted(X509Certificate[] certs, String authType) {
            }

            @Override
            public void checkServerTrusted(X509Certificate[] certs, String authType) {
            }
        }};

        SSLContext sc = SSLContext.getInstance("SSL");
        sc.init(null, trustAllCerts, new SecureRandom());
        HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
        HttpsURLConnection.setDefaultHostnameVerifier((arg0, arg1) -> {
            Log.e("verify_url","is => "+arg0);
            if(arg0.equals("") ){
                return true;
            }else{
                return false;
            }
        });
    } catch (Exception ignored) {
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM