Android Google Maps is blank in Signed APK
Holly Molly, I ended up figuring out that the link in my dubug
google_maps_api.xml
contains the debug SHA-1 which it passes to Google Cloud Platform to whitelist the debug build for using the GoogleMaps api key that it will use.
This therefore means that if you build a release APK, the SHA-1 will be different.
How do you get the Release SHA-1? You do your Build->Generate Signed Bundle
and follow the steps. Take note of where the .keystore file is saved. I used desktop.
Once you have done that, have a look at the screenshot in my question. It states using keytool -list ...etc
to view the SHA-1 for the generated APK.
Once you have your SHA-1 showing, go to Google Cloud Platform, and into APIs, and into Maps SDK for Android. Click on the edit icon for the app that you wish to use the API for. You should now see a list titled API restrictions
where there should be a list already containing the SHA-1 for your debug build.
Copy your SHA-1 from Terminal, (found by running that keytool -list ...etc
) command. Paste it as a new 'item' in that Android app restrictions list. Save, if there is a save button.
You should be good to go from here on .
Or you could just un-restrict your API key usage, which is not recommended.
Android Studio - Google map still blank on real Android device on release apk
Make sure you enter your release API key in the google_maps_api.xml under the release folder.
First, switch to Project view by using the dropdown in the upper left of the Project Explorer. Then, expand app/src/
, and you will see subfolders debug
and release
. Under there, you should see two separate google_maps_api.xml files under debug/res/values
and release/res/values
.
Make sure that the release API key is in the google_maps_api.xml file under the release/res/values
folder, since this is the one that will be used for the signed release apk.
Google Maps not showing after debug and release APK
You need to add SHA-1 to Cloud Console project you are using the API in. For debug and unpublished release add the one you get from Android Studio after running signingReport.
If you are publishing the app and using Play Console signing you also need to add that SHA-1 as well.
Release APK file not showing google maps
Reason for this issue
This occurred because there are different SHA1
s in debug
and release
types.
Fix for this issue
Add the SHA1
of the keystore used to build the release
APK
to Google console
Steps:
Get the path of the keystore when you generate signed APK
Build ----> Generate Signed APK..
Save the key store path
Remember to make Build Type --- release
- Extract
SHA1
from the keystore.
Open your terminal use command below:
keytool -list -v -keystore "/Users/NT/Desktop/generalkey.jks"
You will be asked for password for your keystore.
Change path to your keystore path keytool -list -v -keystore "keystore path"
From the Certificate fingerprints, you will see the SHA1
- Generate android key using this
SHA1
and your package name
Generate APK using keystore and enjoy your map
Android Google Maps works on emulator but not on real device
I found the solution. Now fingerprint of release certificate is useless. To get map working you need to go to Google Play Console -> choose app -> Release management -> App signing and use fingerprint from App signing certificate.
Google Map not working in Release APK, but working correct in Debug APK
Debug certificate is different from your production certificate. You need to add both to your Google Maps key entry in your API console as seaparate row - each with the same packageId, but naturally different SHA1 hash.
OR
Maybe you have two google_maps_api.xml files, one in the app/src/debug/res/values folder and the other in the app/src/release/res/values folder, but only the debug one contains your API key.
Unable to view Maps with Debug/Release APK release
I was finally able to fix this issue and these were the steps I followed [on a windows machine, should be much more easier on a mac]:
a) cd into C:\Program Files\Java<jdk version>\bin [or wherever your jdk is installed].
b) Run: keytool -list -v -alias -keystore "{keystore ie., .jks file loc}" -storepass {your store password} -keypass {your keypass}
c) By running the keytool cmd, your SHA1 file would then be generated.
d) Login to https://console.developers.google.com/
e) In your project there will be a google_maps_api.xml file. In this file there is a commented url, something like this: https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r={your SHA1 key}%3B{your project package}.
f) In the link above, replace the default SHA1 key with the newely generated key and open the link on a browser from where you already have logged into google develover console.
h) Follow the steps as prompted on the browser and with this you should be able to generate an API key.
i) Paste the generated API key here:
<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">API key</string>
This is available on your google_maps_api.xml file.
j) Now go to {your project location}\app\src\release\res\values and open the google_maps_api file. Here again, replace your API key in the location mentioned in point (i) ie., the code snippet.
k) Finally go to Android Studio > Your Project > Build > Generate Signed Bundle / APK > {input keystore path and passwords as per point (b)} > select debug/release version > Finish
The debug or release apk generated will now allow you to access google maps.
Related Topics
Android Marshmallow Request Permission
Creating a System Overlay Window (Always on Top)
How to Get Extra Data from Intent on Android
Libraries Do Not Get Added to Apk Anymore After Upgrade to Adt 22
Retrieve a Fragment from a Viewpager
Install Application Programmatically on Android
Difference Between Gravity and Layout_Gravity in Android
How to Correctly Save Instance State of Fragments in Back Stack
Getting the Screen Density Programmatically in Android
Understanding Fragment'S Setretaininstance(Boolean)
Download Binary File from Okhttp
How to Save Users Score in Firebase and Retrieve It in Real-Time in Android Studio