Dennis Zinkovski
Dennis Zinkovski

Reputation: 1851

Google Maps v2 Authorization failure. Different SHA1

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

Google Maps API v2 is Enabled and API key is correct

I just chose GoogleMapsActivity in "New project", then created a key.jks, created sha1 by keytool, created public api 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 the new key.jks (and all over 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" />
<!--

The ACCESS_COARSE/FINE_LOCATION permissions are not required to use Google Maps Android API v2, but are 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 in google dev. console and in logs, how to deal with that?

Can anyone help with advice.

Upvotes: 3

Views: 6727

Answers (3)

Daniel Nugent
Daniel Nugent

Reputation: 43322

It sounds like you're using the SHA1 fingerprint from the keystore that you will be using to generate a signed apk.

For debugging/running 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 by using 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 password "android".

However, since you already have the correct value in your logs, just copy this from your logs (I modified it here, don't copy from 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 that into your API Key in the developer console.

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

You can also configure a different API key for debug and release, if you do that take a look at this answer.

Upvotes: 11

Pierangelo Orizio
Pierangelo Orizio

Reputation: 824

Check if you have included your signature key in debug and release mode, read this: http://developer.android.com/tools/publishing/app-signing.html#cert

Upvotes: 0

Rene Limon
Rene Limon

Reputation: 624

add the following in 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" />

also:

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

Upvotes: 0

Related Questions