簡體   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