Android Google Maps Fail to Load on Release Build
July 21, 2018SHA-1 signing-certificate fingerprint is included for signed apk
This article is related to Setup Android Google Maps (Google Play Version 15).
When Google Maps loades successfully on debug build but not release/signed apk, if could be due to Google API Console SHA-1 configuration or API Key configuration.
SHA-1 signing-certificate fingerprint for Google API console
Usually the first thing we suspect is did we include the SHA-1 signing-certificate fingerprint for the release build/signed apk?
Goto Google API console -> Credentials -> API keys
. Check
API key
matching the one ingoogle_maps_api.xml
orAndroidManifest.xml
- Make sure
Package name
andSHA-1 certificate fingerprint
is available for both debug and release build.
NOTE: Refer to Get SHA-1 Fingerprint Of Keystore Certificate
TIPS: You can build both debug and release with the same key. Refer to Android Studio Build Debug Apk With Release Key.
Missing google_maps_api.xml release configuraion
If you are using google_maps_api.xml
, you might not realize there are actually 2 versions of the file at the following location
app/src/debug/res/values/google_maps_api.xml
app/src/release/res/values/google_maps_api.xml
NOTE: You will notice which build variant you are editing by seeing google_maps_api.xml (debug)
in the Android project panel.
To edit the release version, Android Studio -> Build Variants (Left-lower corner)
, change to release build. You shall now see google_maps_api.xml (release)
.
Another way is to change Android
to Project
in Project panel and locate the files.
Store API Key in build.gradle with manifestPlaceholders
I prefer configure and store the api key in build.gradle (Module:app)
file and discared the usage of google_maps_api.xml
.
android {
compileSdkVersion 27
defaultConfig {
...
}
buildTypes {
debug {
manifestPlaceholders = [googleMapsKey: 'YOUR_API_KEY']
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
manifestPlaceholders = [googleMapsKey: 'YOUR_API_KEY']
}
}
}
Edit AndroidManifest.xml
.
<manifest ...>
<application ...>
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="${googleMapsKey}" />
</application>
</manifest>
- algo-trading
- algolia
- analytics
- android
- android-ktx
- android-permission
- android-studio
- apps-script
- bash
- binance
- bootstrap
- bootstrapvue
- chartjs
- chrome
- cloud-functions
- coding-interview
- contentresolver
- coroutines
- crashlytics
- crypto
- css
- dagger2
- datastore
- datetime
- docker
- eslint
- firebase
- firebase-auth
- firebase-hosting
- firestore
- firestore-security-rules
- flask
- fontawesome
- fresco
- git
- github
- glide
- godot
- google-app-engine
- google-cloud-storage
- google-colab
- google-drive
- google-maps
- google-places
- google-play
- google-sheets
- gradle
- html
- hugo
- inkscape
- java
- java-time
- javascript
- jetpack-compose
- jetson-nano
- kotlin
- kotlin-serialization
- layout
- lets-encrypt
- lifecycle
- linux
- logging
- lubuntu
- markdown
- mate
- material-design
- matplotlib
- md5
- mongodb
- moshi
- mplfinance
- mysql
- navigation
- nginx
- nodejs
- npm
- nuxtjs
- nvm
- pandas
- payment
- pip
- pwa
- pyenv
- python
- recylerview
- regex
- room
- rxjava
- scoped-storage
- selenium
- social-media
- ssh
- ssl
- static-site-generator
- static-website-hosting
- sublime-text
- ubuntu
- unit-test
- uwsgi
- viewmodel
- viewpager2
- virtualbox
- vue-chartjs
- vue-cli
- vue-router
- vuejs
- vuelidate
- vuepress
- web-development
- web-hosting
- webpack
- windows
- workmanager
- wsl
- yarn