1
votes

OK, so I know that there have been many questions relating to this subject, but it still doesn't seem to work for me. Anyway, here goes:

My app uses a Google map fragment. To display the map, I got a debug certificate from Google and put it in my Android Manifest. Everything worked perfectly.

Now, I'm ready to publish my app on the Play Store. So, I generated a signed APK, creating my keystore in the process. I also had to change my app's package name, since Google doesn't accept package names with com.example.appname.

So now, I need to get another release certificate from Google for the map in order to publish my app, right? So I followed through with the instructions over here: https://developers.google.com/maps/documentation/android/start

I got the SHA1 fingerprint from my keystore (which is different from my debug SHA1 fingerprint used for my debug certificate), and plugged it in to my credentials in the Google Developer Console with my updated package name to get a release key. Then, I replaced my previous debug key with the new release key, and rebuilt my project, but I get the following error from Logcat:

Authorization failure.  Please see https://developers.google.com/maps/documentation/android/start for how to correctly set up the map.
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:

Now here, it shows the new release key I just plugged into my manifest, but it shows my old debug SHA1 fingerprint instead of the one in my keystore, so the map never shows up, and there is only a gray screen in its place. Here's part of my Android Manifest, I also have all the required permission in as well:

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

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_myicon"
    android:label="MyApp"
    android:theme="@style/AppTheme" >

    <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="(My release key)" />

    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />

Here is my build.grade file:

    apply plugin: 'com.android.application'

    android {
      compileSdkVersion 21
      buildToolsVersion "21.1.1"

    defaultConfig {
        applicationId "(my package name)"
        minSdkVersion 14
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }


    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'com.google.android.gms:play-services:6.5.87'
}

Perhaps there is a mismatch between the new release key and old debug SHA1 fingerprint, and if there is, why isn't everything updating properly? I would greatly appreciate if anyone can help me out this.

1
Are you running from Android Studio, or are you running the signed apk? Also, be sure to uninstall the app when you switch from debug to release, and release to debug.Daniel Nugent
@DanielNugent I'm running from Android Studio, though running the APK doesn't work either. I already tried uninstalling it and installing it again...Nisarg
Add your debug sha1 to your new api key for running from Android Studio! Also, did you rebuild your signed apk with the new API key?Daniel Nugent
@DanielNugent Can you please tell me how you would do that? I did rebuild my signed APK, though.Nisarg
You can add multiple sha1;package values to an API key in the developer console, one per line.Daniel Nugent

1 Answers

0
votes

You need to add signingConfigs to your build.gradle (Module:app) file.

This is what my file contains -

android {
compileSdkVersion 21
buildToolsVersion '21.0.1'

defaultConfig {
    applicationId "com.example"
    minSdkVersion 16
    targetSdkVersion 21
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
signingConfigs {
    release {
        storeFile file('Path\\YourReleaseKey.jks')
        storePassword 'password'
        keyAlias 'YourAlias'
        keyPassword 'password'
    }
}
buildTypes {
    release {
        signingConfig signingConfigs.release
    }
}