I've seen this question a lot on Internet but nothing works for me.
I have my Android app which uses Google Maps services to display a map.
I've set up two variants: debug and release.
The debug variant has no signing at all, while the release does. I created the corresponding my_app.jks keystore, which is placed in my main /app folder.
My release variant is configured as:
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
and the values are set in release-keystore.properties at root level.
In GCP, I generated an API KEY and restricted it to Android apps with both: debug and release fingerprint.
My release fingerprint was created following Google's documentation:
keytool -list -v -keystore your_keystore_name -alias your_alias_name
I entered the requested password and it output the SHA-1 fingerprint. That fingerprint was the one I set on GCP with the correct package name com.my_app.
Then, I run the command
./gradlew :app:bundleGooglePlayRelease
to create the bundle which I manually upload to Google Play Store for Internal Testing. I downloaded the app but the map remains grey.
For my understanding, as the bundle is signed up with the release keystore, the SHA-1 is linked to that bundle so should be enough to authenticate the API KEY.
Things I've tried but didn't work:
- Run the release variant in an emulator (show grey map, too)
- Hardcode the MAPS_API key is directly in project's Android Manifest to ensure the value is correct
- Creating a separate API KEY, to check there's no issue with restricting the same package name to two different fingerprints
- Try to generate the release fingerprint with wrong keystore values to ensure I have not mistyped any value
- The build failed, so the values I've used were correct
UPDATE
Following this solution, I got the SHA-1 from code and printed it. It turns out, it is a different than the one I've locally obtained with the keytool command.
I will work on figuring out why they differ. Any help is welcome.
After some researching and, as Martin Zeitler commented, it was not authenticating the API KEY since the app is using the SHA-1 from Google App Signing
There are three fingerpints:
linking that SHA-1 to the API KEY, solves the problem