How to change SHA1 fingerprint in an android app

3.6k views Asked by At

Try to design simple google map related application. App runs fine in debug mode but when i switch to release mode by recreating and changing the Google Map API Key by providing release SHA1 fingerprint and package name in App, also change the build type to release by providing proper config file.

But when i run an app get a following error

Ensure that the "Google Maps Android API v2" is enabled.
Ensure that the following Android Key exists:
API Key: Google Map API Key (with release SHA1 fingerprint)
Android Application (<cert_fingerprint>;<package_name>): Debug SHA1 fingerprint;com.mycompany.packagename

i am stuck here and not able to change the SHA1 fingerprint in App to release one. Please help me in resolving this issue.

1

There are 1 answers

0
Sajal Mittal On BEST ANSWER

Finally i figure out the problem. Signing during the build using GUI doesn't work. So for checking the release version you need to change the Gradle as follows and sync the project.

apply plugin: 'com.android.application'

android {
signingConfigs {
    debug {
        storeFile file('debug.keystore')
    }
    release {
        keyAlias 'Key'
        keyPassword 'Pass'
        storeFile file('C:/Users/hp/AndroidStudioProjects/project/key.keystore')
        storePassword 'Pass'
    }
}
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
    applicationId "com.mycompany.mypackage"
    minSdkVersion 15
    targetSdkVersion 21
    versionCode 6
    versionName "6.0"
}
buildTypes {
    debug {
        signingConfig signingConfigs.release
    }
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        signingConfig signingConfigs.release
        debuggable false
    }
}
}

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

After checking the release version of App. Run "assemblerelease" and find the release apk in the following path \build\outputs\apk*release.apk

I think this solution works for others.

Thanks