Google Maps v2 authorization error. Various SHA1

I have read all similar questions and did everything that was described in them but did not help.

Google Maps API v2 enabled and Correct API key

I just selected GoogleMapsActivity in "New project", then created key.jks, created sha1 with keytool, created api public access key, put my API key in manifest.

I tried: clean-rebuild-unistall app-install
updated api key many times
create a new project with new .jks key (and again)
delete and create api key

Here is my manifest:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dandewine.user.thinkmobiletest" >

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<!--

      

ACCESS_COARSE / FINE_LOCATION permissions are not required to use Google Maps Android API v2, but it is recommended. ->      

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="AIza**************************" />

    <activity
        android:name=".ActivityMain"
        android:label="@string/title_activity_activity_main" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

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

      

Here is my activity:

public class ActivityMain extends FragmentActivity implements OnMapReadyCallback {


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fragment_map);

    SupportMapFragment mapFragment = (SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);
}

@Override
public void onMapReady(GoogleMap googleMap) {
    googleMap.addMarker(new MarkerOptions()
            .position(new LatLng(0, 0))
            .title("Marker"));
}

      

Logcat:

E/Google Maps Android APIοΉ• Authorization failure.  Please see            https://developers.google.com/maps/documentation/android/start for how to correctly set up the map.
07-27 14:52:37.551  25002-25035/com.dandewine.user.thinkmobiletest E/Google Maps Android APIοΉ• In the Google Developer Console (https://console.developers.google.com)
Ensure that the "Google Maps Android API v2" is enabled.
Ensure that the following Android Key exists:
API Key: AIza****************************
Android Application (<cert_fingerprint>;<package_name>): 8C:2B:4C:F7:CF:FB:EC:D5:DC:D7:D0:5D:6E:30:49:74:97:18:57:88;com.dandewine.user.thinkmobiletest

      

UPDATE . I have different SHA1 fingerprints on google dev. console and logs, how to deal with it?

Can anyone help with tips.

+3


source to share


3 answers


It looks like you are using the SHA1 fingerprint from the keystore that you will use to generate the signed apk.

To debug / run from Android Studio, you need to use the SHA1 fingerprint that Android Studio uses to sign the apk.

Note that you can get this SHA1 fingerprint using the command line:

For Mac or Linux:

keytool -list -v -keystore ~/.android/debug.keystore

      

For Windows:

keytool -list -v -keystore C:\User\YourUser\.android\debug.keystore

      



with the password "android".

However, since you already have the correct value in your logs, just copy this from your logs (I changed it here, don't copy it here):

8C:2B:4C:F7:CF:FB:EC:D5:DC:D7:D0:5D:6E:30:49:xx:xx:xx:xx:xx;com.dandewine.user.thinkmobiletest

      

And paste this into your API key in the developer console.

You can add multiple fingerprint / bundle values ​​to each API key, one per line (you can also see this in the instructions when editing an API key).

You can also set up a different API key for debug and release, if you do see this answer .

+10


source


add the following in the manifest:

<permission
    android:name="com.dandewine.user.thinkmobiletest.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="com.tp.lib.tp.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

      



and

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

      

0


source


Check if your signing key is enabled in debug and release mode, read the following: http://developer.android.com/tools/publishing/app-signing.html#cert

0


source







All Articles