getting Failed to load map. Error contacting Googl

2019-02-26 15:55发布

问题:

I read all the post concering this issue and yet I wasnt able to solve it on my mechine. I allways get:

06-23 20:04:30.011: E/Google Maps Android API(6623): Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).

when getting to the map activity.

my code:

    <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.mobwal"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="14" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <permission android:name="com.mobwal.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
    <uses-permission android:name="com.mobwal.permission.MAPS_RECEIVE"/>
    <uses-permission android:name="com.google.android.providers.gsf.permissions.READ_GSERVICES"/>

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/logo1small"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.NoTitleBar" >

        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="KEYFROM GOOGLES CONSOLE" />

        <activity
            android:name=".FacebookStart"
            android:label="@string/app_name"
            android:windowSoftInputMode="adjustResize" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name="com.facebook.LoginActivity"
            android:label="@string/app_name"
            android:theme="@android:style/Theme.Translucent.NoTitleBar" />

        <meta-data
            android:name="com.facebook.sdk.ApplicationId"
            android:value="@string/facebook_app_id" />    

    </application>

</manifest>

I got my SHA1 fingerprint from eclipse preferences and it is the same as I had using key tool. the thing is that I had two .android folders(one on C:\Users\user_name.android and on my android sdk folder) I delete the one on the user's after trying to activate my app using it (without success and now it is not recreated) so I got left only with the one under my android sdk folder which is not helping much. I need help I tried almost anything.

回答1:

Go to https://code.google.com/apis/console Once logged in, go to Services > Google Maps Android API v2 and switch on this toggle button.

Careful: it's "Google Maps Android API v2" and not "Google Maps API v2".



回答2:

For those to whom none of the answers work, in my case the problem was, that there was another android app key registered for the same package name on another account's console, so the maps api was finding that, and failed to authenticate me (obviously). As soon as that has been removed (and the fingerprints added to the one I was using) after removing and installing the app again on the phone everything started to work.



回答3:

This is keystore issue on 99%.

1) I use for release and debug the same file debug.keystore which I copy from C:/Users/EEfimenko/.android/debug.keystore to C:\Users\EEfimenko\Android\MyApp\app folder for access directly like to debug.keystore without C:/Users/... link

2) Then I add point to it from build.gradle(Module: app) file inandroid`:

signingConfigs {
    debug {
       storeFile file('debug.keystore')
     }
    release {
       storeFile file('debug.keystore')
     }
}

3) Run keytool -list -v -keystore debug.keystore command from cmd from C:\Users\EEfimenko\Android\MyApp\app folder and mix resulted SHA1 fingerprint with name of applet: FR:TY:CG.....YF:ER;com.myapp.nameofit

4) Go to https://code.google.com/apis/console/b/0/?noredirect to:

a) Services and enable "Google Maps Android API v2" to ON state

b) Put FR:TY:CG.....YF:ER;com.myapp.nameofit in "API Access" like Create new Android Key

Now you can see your map with key again like at beginning without key!:)



回答4:

I tried to do almost everything like generating the key for 20 times, changing the order of the permissions, but there is nothing batter than just removing the project from workspace and importing it back again.



回答5:

Problem is: work without key, but doesn't work with it, because you touch "app" file by your hand from editor. You must edit it and make changes only from: File -> Project structure



回答6:

You need to find file \app\src\release\res\values\google_maps_api.xml in your project and place there your Google API KEY because Android Studio show you only google_maps_api.xml from debug folder for debug version. Than all will work and map will show not only in debug mode;)