I'm currently developing an application for Android and I'm using Google Maps API. In developer console, I added my SHA1 certificate print, followed by my package name.
Even though I put this SHA1 certificate print using keytool, I can't access to the maps.
I made lots of search, but every topics brought me to answers where error were in a wrong API Key in developer console.
But I took the right SHA1, the one of my certificate.
Thanks in advance !
My Map in release mode was showing but after I publish to Play Store it was not showing.
I had mentioned both debug and release certificate SHA-1 Key to Google Developer Console but map in release mode after downloading app from play store was still not showing.
Here' what was problem:
Google Play App Signing is enabled for this app
Goto Release Management -> App Signing -> and copy the SHA-1 certificate fingerprint from App signing certificate
Or
Release -> Setup -> App Integrity -> App Signing
Paste this newly copied SHA-1 fingerprint to Developer Console and map in release mode will show.
I had this same problem, it was super frustrating. What I ended up doing was taking the key I made using my release keystore and putting it in the google developers console. Then, added the following into the android manifest.
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="KEY GOES HERE"/>
I'm sure you read the documentation on this, but make sure you follow the instructions for the release certificate to the dot.
https://developers.google.com/maps/documentation/android/signup
You could also follow the link that was generated for you in the google_maps_api.xml file. This automates the process of entering the key into the developer console. However, make sure you still add that meta data value into your manifest.
The file google_maps_api.xml has to be under res/debug/ and res/release. The editor only shows your current run configuration which is debug by default and is a bit misleading if you do not observe the (debug) note after the folder name. Copy the google_maps_api.xml into both folder and edit make sure they have the correct API keys ofr each build.
Android Studio also creates a TODO in the release folder for the google_maps_api xml file and lets you know of the required procedure before release. Also please do not change the key in manifest manually. When you switch to a release variant, the key is automatically updated in the manifest.
In any case do this,
Go to the link as mentioned by #Andrew Brook
Click "Get a key" and continue
Either create a new project or use an existing one
Specify the options and click the button
If you already had made one before, for let's say for debug, then go to Create a new api key
Image here
Add the required name, click on "Add package name and fingerprint"
Add your app's package name and SHA-1 key (generete it using keytool in java/jdk../bin/)
Image here
You get your "release" variant API key to be added in the google_maps_api.xml in the release folder.
You have to Enable the SHA key In Google Developer Console
so at 1st go to release Management get your app SHA key (1st one )
then Follow this link
https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r=(Your SHA KEY)%3B(YOUR PACKAGE NAME)
Now it Will Enable the API .
now update your app with the new key .
It will Work .
Related
I want to generate and use a google API key.
enabled google maps v2 API
created project with one activity with google map (default wizard in studio)
created key on google for debug project, assigned SHA1;app package of application to the project key on google
API key inserted into google_maps_api.xml (AndroidManifest.xml updated automaticaly)
build & run on AVD on which the app is working, map is shown.
Then:
API already enabled
in Android studio created keystore for release (keystore.rel.jks)
generated fingerprints (keytool -list -v -keystore C:\Dropbox\AndroidKeyStore\keystore.rel.jks)
on google added new fingerprint to the new release project (release SHA1;app package) - key generated AIza...
API key inserted into google_maps_api.xml (AndroidManifest.xml updated automatically)
generate signed app (using keystore.rel.jks) & install on real device ... app is working, map is STILL BLANK, only zoom buttons and Google label is on
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.
i was tired of trying over and over again, it turns out that PlayStore has something called App signing certificate, and the map works after i copy that sha1 and paste it in the google console for the android map.
When you try to create map api key please make sure the url contain correct package name. It should not take any sub package like this.
wrong package :com.gpslocation.trackerpro.Activities
correct package :com.gpslocation.trackerpro
After editing don't forget to save
Go to https://play.google.com/apps/publish/ and then to App signing:
Maybe you will see this:
If that is the case, maybe you are a developer and not the account owner. You will have to contact the account owner and ask him/her to complete that process. Follow this article about how to do that:
https://learnfreecoding.com/how-to-sign-your-android-app-with-signed-key-private_key-pepk/
The account owner will get to this screen:
Ask them to choose Upload a key exported from Android Studio. They will have to upload a private_key.pepk file. This is how you get that file from Android Studio:
Go to Build > Generate Signed Bundle / APK....
Select Android App Bundle and click Next:
Provide the corresponding credentials and make sure to put the check on for Export encrypted key for enrolling published apps in Google Play App Signing.
Specify the destination folder and make sure you select release before you click Finish:
That will generate the private_key.pepk file that you need to provide to Upload a key exported from Android Studio.
After doing the above, when you to to the App signing section of your app, you will see something like this:
Then you will see the Google Maps working correctly on real Android Studio physical devices and not only on the Android Studio Emulator. This was the solution for me.
generally you must do below steps:
1- Create New maps Activity in android studio
2- In google_maps_api.xml open the link in line 3
3- Confirm data and get key in Firebase
4- Copy key in google_maps_api.xml debug and release
5- Get release SHA1 in gradle tab -> signing report
useful link for get sha1
useful link for sign application in debug mode to get sha1
Make sure you enable the Maps for Android app in Google Console.
Make sure the map key you entered in google_maps_api.xml file is the same android key, generated by google console.
You can also try a new key.
Got stuck on this issue for a day. I tried everything and eventually found the following code in my manifest:
<supports-screens
android:anyDensity="false"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="false"
android:xlargeScreens="true" />
After removing these lines my maps displayed correctly.
I faced the same problem, in my case fingerprint of my package used in google map API key was mismatched so what i did:
Create a new google map activity.
Go to google_maps_api.xml.
Copy the link given in that file in paste in browser(login to google account).
On google create some project here and press continue
Click on create API key
Copy the key and paste in google_maps_api.xml
string name="google_maps_key" templateMergeStrategy="preserve" translatable="false"YOUR KEY HERE
And execute the application
Do not use below fingerprint, or key, create your separate it is based on package ans application
Please follow these steps:
Go to Google Play Console -> Setup -> App integrity -> App signing key certificate
Copy the SHA-1 certificate fingerprint
Open Google Cloud Platform
Go to APIs & Services -> Credentials
Click on your API key
Go to Application restrictions -> Restrict usage to your Android apps
Click on ADD AN ITEM
Add your package name with the copied SHA-1 certificate fingerprint
Wait for around 10 mins. and your maps would be visible on your published app.
I want to generate and use a google API key.
enabled google maps v2 API
created project with one activity with google map (default wizard in studio)
created key on google for debug project, assigned SHA1;app package of application to the project key on google
API key inserted into google_maps_api.xml (AndroidManifest.xml updated automaticaly)
build & run on AVD on which the app is working, map is shown.
Then:
API already enabled
in Android studio created keystore for release (keystore.rel.jks)
generated fingerprints (keytool -list -v -keystore C:\Dropbox\AndroidKeyStore\keystore.rel.jks)
on google added new fingerprint to the new release project (release SHA1;app package) - key generated AIza...
API key inserted into google_maps_api.xml (AndroidManifest.xml updated automatically)
generate signed app (using keystore.rel.jks) & install on real device ... app is working, map is STILL BLANK, only zoom buttons and Google label is on
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.
i was tired of trying over and over again, it turns out that PlayStore has something called App signing certificate, and the map works after i copy that sha1 and paste it in the google console for the android map.
When you try to create map api key please make sure the url contain correct package name. It should not take any sub package like this.
wrong package :com.gpslocation.trackerpro.Activities
correct package :com.gpslocation.trackerpro
After editing don't forget to save
Go to https://play.google.com/apps/publish/ and then to App signing:
Maybe you will see this:
If that is the case, maybe you are a developer and not the account owner. You will have to contact the account owner and ask him/her to complete that process. Follow this article about how to do that:
https://learnfreecoding.com/how-to-sign-your-android-app-with-signed-key-private_key-pepk/
The account owner will get to this screen:
Ask them to choose Upload a key exported from Android Studio. They will have to upload a private_key.pepk file. This is how you get that file from Android Studio:
Go to Build > Generate Signed Bundle / APK....
Select Android App Bundle and click Next:
Provide the corresponding credentials and make sure to put the check on for Export encrypted key for enrolling published apps in Google Play App Signing.
Specify the destination folder and make sure you select release before you click Finish:
That will generate the private_key.pepk file that you need to provide to Upload a key exported from Android Studio.
After doing the above, when you to to the App signing section of your app, you will see something like this:
Then you will see the Google Maps working correctly on real Android Studio physical devices and not only on the Android Studio Emulator. This was the solution for me.
generally you must do below steps:
1- Create New maps Activity in android studio
2- In google_maps_api.xml open the link in line 3
3- Confirm data and get key in Firebase
4- Copy key in google_maps_api.xml debug and release
5- Get release SHA1 in gradle tab -> signing report
useful link for get sha1
useful link for sign application in debug mode to get sha1
Make sure you enable the Maps for Android app in Google Console.
Make sure the map key you entered in google_maps_api.xml file is the same android key, generated by google console.
You can also try a new key.
Got stuck on this issue for a day. I tried everything and eventually found the following code in my manifest:
<supports-screens
android:anyDensity="false"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="false"
android:xlargeScreens="true" />
After removing these lines my maps displayed correctly.
I faced the same problem, in my case fingerprint of my package used in google map API key was mismatched so what i did:
Create a new google map activity.
Go to google_maps_api.xml.
Copy the link given in that file in paste in browser(login to google account).
On google create some project here and press continue
Click on create API key
Copy the key and paste in google_maps_api.xml
string name="google_maps_key" templateMergeStrategy="preserve" translatable="false"YOUR KEY HERE
And execute the application
Do not use below fingerprint, or key, create your separate it is based on package ans application
Please follow these steps:
Go to Google Play Console -> Setup -> App integrity -> App signing key certificate
Copy the SHA-1 certificate fingerprint
Open Google Cloud Platform
Go to APIs & Services -> Credentials
Click on your API key
Go to Application restrictions -> Restrict usage to your Android apps
Click on ADD AN ITEM
Add your package name with the copied SHA-1 certificate fingerprint
Wait for around 10 mins. and your maps would be visible on your published app.
I applied the exact steps as mentioned in the google developer doc to create an example google map project and everything went fine on the emulator, but when I generated the project apk file and launched it on real device Samsung Galaxy S4 google map doesn't show up it shows only a blank background with just colored Google logo appearing on the left lower screen corner !!
I created new project for google map I created new .jks file for the project and created store and key pass and alias then I extracted the SHA1 from cmd java bin I went to dev.google.com/console created new project then enabled google maps android API then created API key from Credentials pasted this API key in place in google_maps_api.xml in my project updated the signingConfigs release with the .jks file path and alias and two passwords. then generated signed APK from Android Studio then transferred the app-release.apk to real device then installed it same problem google map NOT showing.
Reason for this issue
This occurred because there are different SHA1s 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
It might be silly but I had my API key included in
app\src\debug\res\values\google_maps_api.xml (debug)
You also need to include in-
app\src\release\res\values\google_maps_api.xml (release)
if any one still facing this problem :
this happend to me because we need two google maps api keys one for the debug and another one for the release, you can check in :
C:\Users\username\AndroidStudioProjects\yourapp\app\src\ debug \res\values
and you'll find an xml with your api key like:
<string name="google_maps_key" templateMergeStrategy="preserve"
translatable="false">AIza...etc</string>
but if you check here:
C:\Users\username\AndroidStudioProjects\yourapp\app\src\ release \res\values
you will find an xml but without api key inside like:
<string name="google_maps_key" templateMergeStrategy="preserve"
translatable="false">YOUR_KEY_HERE</string>
it was noted as a comment inside the xml file itself :
Before you release your application, you need a Google Maps API key.
To do this, you can either add your release key credentials to your existing
key, or create a new key.
Note that this file specifies the API key for the release build target.
If you have previously set up a key for the debug target with the debug signing certificate,
you will also need to set up a key for your release certificate.
Follow the directions here:
https://developers.google.com/maps/documentation/android/signup
Once you have your key (it starts with "AIza"), replace the "google_maps_key"
string in this file.
Check the following things:
This below file should be in both debug and release
app\src\debug\res\values\google_maps_api.xml (debug)
You also need to include in
app\src\release\res\values\google_maps_api.xml (release)
Add the SHA1 for release apk into Google Api Console.
You can get SHA1 key from play console >> App Signing >> SHA1 Certificate
Another additional step:
In google play developer console add App Signing SHA1 fingerprint:
now google signed apk before publish on store,so go to google pushish app ---> app signning , and add signed key to google developer console,you shoud add 3 key sha1 : debug,release and new sha1 key after pushlish
if signing keys are being managed by google play console, for your case, do this
Get the SHA-1 certificate fingerprint from google play console >> your app >> Setup >> app integrity (this is different than the one you used when you sign your app)
Go to your google cloude api key credentials and add the SHA-1 you took from the google play console.
That is it it worked for me.
Google now signs the APK before publishing on the store. Start by selecting your app in google play. Under Release ---> Setup ---> App integrity. Once there you should see the App signing key Certificate. You will see an additional SHA-1 key.
You'll need to add this key into the google developer console. You should have 3 SHA-1 keys : debug, release and the new SHA-1 key after publishing your app.
For showing the map in release version of android apk, developer needs to add the updated SHA-1 key, created by Google Play console after publishing the application. Go to App Signing section of the console and look for 'App Signing Certificate: SHA-1 Certificate Fingerprint'. Copy the fingerprint and paste it in Google API Console where developer has created the Google API key for map.
for all those out there who tried every thing and still not getting the google map to show up in the release version, try to first:
1- install the release.apk on your phone or emulator
2- open the logcat window and set it on your phone device (if using emulator its set on it by default)
3- open the map and it shows the error like below, copy the key and paste in the value tag below in the Manifest file :
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="" />
I also had the same issue of map when I'm making the apk , make apk in the same system in which system you have made the google map key then the map will work and show perfectly .
I want to generate and use a google API key.
enabled google maps v2 API
created project with one activity with google map (default wizard in studio)
created key on google for debug project, assigned SHA1;app package of application to the project key on google
API key inserted into google_maps_api.xml (AndroidManifest.xml updated automaticaly)
build & run on AVD on which the app is working, map is shown.
Then:
API already enabled
in Android studio created keystore for release (keystore.rel.jks)
generated fingerprints (keytool -list -v -keystore C:\Dropbox\AndroidKeyStore\keystore.rel.jks)
on google added new fingerprint to the new release project (release SHA1;app package) - key generated AIza...
API key inserted into google_maps_api.xml (AndroidManifest.xml updated automatically)
generate signed app (using keystore.rel.jks) & install on real device ... app is working, map is STILL BLANK, only zoom buttons and Google label is on
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.
i was tired of trying over and over again, it turns out that PlayStore has something called App signing certificate, and the map works after i copy that sha1 and paste it in the google console for the android map.
When you try to create map api key please make sure the url contain correct package name. It should not take any sub package like this.
wrong package :com.gpslocation.trackerpro.Activities
correct package :com.gpslocation.trackerpro
After editing don't forget to save
Go to https://play.google.com/apps/publish/ and then to App signing:
Maybe you will see this:
If that is the case, maybe you are a developer and not the account owner. You will have to contact the account owner and ask him/her to complete that process. Follow this article about how to do that:
https://learnfreecoding.com/how-to-sign-your-android-app-with-signed-key-private_key-pepk/
The account owner will get to this screen:
Ask them to choose Upload a key exported from Android Studio. They will have to upload a private_key.pepk file. This is how you get that file from Android Studio:
Go to Build > Generate Signed Bundle / APK....
Select Android App Bundle and click Next:
Provide the corresponding credentials and make sure to put the check on for Export encrypted key for enrolling published apps in Google Play App Signing.
Specify the destination folder and make sure you select release before you click Finish:
That will generate the private_key.pepk file that you need to provide to Upload a key exported from Android Studio.
After doing the above, when you to to the App signing section of your app, you will see something like this:
Then you will see the Google Maps working correctly on real Android Studio physical devices and not only on the Android Studio Emulator. This was the solution for me.
generally you must do below steps:
1- Create New maps Activity in android studio
2- In google_maps_api.xml open the link in line 3
3- Confirm data and get key in Firebase
4- Copy key in google_maps_api.xml debug and release
5- Get release SHA1 in gradle tab -> signing report
useful link for get sha1
useful link for sign application in debug mode to get sha1
Make sure you enable the Maps for Android app in Google Console.
Make sure the map key you entered in google_maps_api.xml file is the same android key, generated by google console.
You can also try a new key.
Got stuck on this issue for a day. I tried everything and eventually found the following code in my manifest:
<supports-screens
android:anyDensity="false"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="false"
android:xlargeScreens="true" />
After removing these lines my maps displayed correctly.
I faced the same problem, in my case fingerprint of my package used in google map API key was mismatched so what i did:
Create a new google map activity.
Go to google_maps_api.xml.
Copy the link given in that file in paste in browser(login to google account).
On google create some project here and press continue
Click on create API key
Copy the key and paste in google_maps_api.xml
string name="google_maps_key" templateMergeStrategy="preserve" translatable="false"YOUR KEY HERE
And execute the application
Do not use below fingerprint, or key, create your separate it is based on package ans application
Please follow these steps:
Go to Google Play Console -> Setup -> App integrity -> App signing key certificate
Copy the SHA-1 certificate fingerprint
Open Google Cloud Platform
Go to APIs & Services -> Credentials
Click on your API key
Go to Application restrictions -> Restrict usage to your Android apps
Click on ADD AN ITEM
Add your package name with the copied SHA-1 certificate fingerprint
Wait for around 10 mins. and your maps would be visible on your published app.
My google map app works fine on device with debug google map API KEY but when I create signed apk for my app with release google map API KEY, it does not display map.
To generate release mode google API KEY , i am using SHA1 fingerprint with my keystore.
And i am also defining "signing and build types" in my project Settings as explained by developer.android.com(http://developer.android.com/tools/publishing/app-signing.html).
Tried every possible solution(removing apk and than reinstalling it again, restarting the device, cleaning the project ). nothing worked.
Anybody have a good solution to my problem please help.
FYI Using android studios platform.
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.
The API key needs to be hardcoded into the Android Manifest, and it doesn't work if it's in a separate resources XML file.
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.
EDIT
There's no limit of how many certificate fingerprints and package names are assigned to single Google Maps key, so unless you need this separated is's perfectly fine to have both development and production builds using the same key. In google console it would be like this (one sha1 is from debug cert, which is the same for all apps you build using this IDE, other is production cert):
83:10:58:52:EF:3B:59:70:2B:28:9E:AE:4F:5E:1D:F0:7E:19:FB:F1;com.foo.bar
AE:4F:5E:1D:F0:7E:19:FB:83:10:58:52:EF:3B:59:70:2B:28:9E:AA;com.foo.bar
or even (but I do not recommend using same key for different apps):
83:10:58:52:EF:3B:59:70:2B:28:9E:AE:4F:5E:1D:F0:7E:19:FB:F1;com.foobar.myapp
AE:4F:5E:1D:F0:7E:19:FB:83:10:58:52:EF:3B:59:70:2B:28:9E:AA;com.foo.bar
EF:3B:59:7E:19:FB:83:10:58:57:AE:4F:5E:1D:F0:2B:28:DE:9E:01;net.something.otherapp
I had this Problem and running these steps I think this way is perfect and complete
For Android Studio:
Build-Generate Signed APK
Copy Key Store Path.
Now open a command prompt and go to C:\Program Files\Java\jdk1.6.0_39\bin> (or any installed jdk version).
Type keytool -list -v -keystore and then paste your Key Store Path (e.g. C:\Program Files\Java\jdk1.6.0_39\bin>keytool -list -v -keystore "E:\My Projects \Android\android studio\signed apks\Hello World\HelloWorld.jks").
Now it will Ask Key Store Password, provide yours and press Enter to get your SHA1 and MD5 Certificate keys.
You Can See SHA1 For Your Debug Certificate and Use in Developer Google
Console
Sorry for replying late. Hope this helps for future.
I use this solution to solve same problem
When we are using Google maps while developing, a default debug.keystore is used which has no password. When we build apk file to upload on Play store new SHA-1 key is made so we have to make new debug.keystore for that. We have to create new API key for that SHA-1.
According to solution How to obtain Signing certificate fingerprint (SHA1) for OAuth 2.0 on Android? we can get SHA-1 for the exported apk file .
After that use that new API key in Android Manifest as the previous one and you are done.
EDIT 1-
Steps to do this
1) Create apk file using "Use the export Wizard" in "Android Manifest" file of your project.
2) After inserting key and before finishing, MD5 and SHA1 keys are shown as shown is this given pic- (http://i.stack.imgur.com/SldEv.png)
3) Create new API Key for Android project in https://console.developers.google.com for new SHA1 which is retrieved in point 2).
4)Use that API key in manifest file as shown below
5)Clean your project and build APK file again as per point 1).
6) You can see google maps now in that apk.
There are two things to remember and get this working.
Debug Build Variant
Generate a new android debug key using the keytool
Associate this key (SHA-1) with the android map api key on google console
The debug mode has a google_maps_api.xml where the android maps api key is stored (src/debug/.../google_maps_api.xml) as a string "google_maps_key"
Release Build Variant
Generate a new android release key using the keytool
Assoiciate this key (SHA-1) with a new android map api key on google console
The release mode has a google_maps_api.xml where the release android maps api key is stored (src/release/.../google_maps_api.xml) as a string "google_maps_key".
In the AndroidManifest.xml add the following line :
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="#string/google_maps_key" />
Follow the normal procedure for debug and release. It should work seamlessly.
create another Maps API key (to put in your manifest) corresponding with you release
keystore for release.
check Google's documentation
you cannot use same key that you used in debug in the release, they have different works.
to solve this problem you have to generate new Google map key API KEY form the key store that you are using in you release copy
see this video for more details
https://www.youtube.com/watch?v=xLJ0jDFdUZ0
for futures refs ---my case--- there are two google_maps_api.xml files where you need to put your google api key. You can very easily do the mistake to replace YOUR_API_KEY in only one of them (especially if you just deleted the google api/app and created new ones)
In the Google Api console, where we have created the API KEY we have an option to add multiple finger prints to the same key. What I did was adding two SHA1 finger print for my debug keystore and release keystore and the same API key worked for me.
Note the below is for Ubuntu specifically:
Get SHA1 for the debug using the below command
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
For getting SHA1 for release the command changes to
keytool -list -v -keystore /home/atul/Desktop/Learnings/Projects/TestApp/keystore.jks -alias test -storepass password -keypass password
where
/home/atul/Desktop/Learnings/Projects/TestApp/keystore.jks is the path where my keystore file for the signed apk is present
test is the key alias name used while genrating the signed key store
and password is the password used while signing the apk
Hope this helps. Happy coding :)
I had a similar issue and the problem was that I generated the apk from Android Studio without first selecting the right flavour. This means my manifest was still using the Google Maps API key that I created for the debug flavour.
Please make sure you select the release flavour in your Android Studio. See screenshot below:
How do I get the release api SHA1 fingerprint:
install your signed APK, from Playstore, or just copying it to the phone.
Plug USB cable if it is a real phone, and open Android Studio.
The first time you try to get maps, a Log entry will show something like:
E/Google Maps Android API: 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:
API Key: AIzaS<YOUR KEY YOUR KEY YOUR KEY YOUR KEY>
Android Application (<cert_fingerprint>;<package_name>): 56:AF:B2:<THIS IS WHAT YOU ARE LOOKING FOR>;br.com.tinx.<your package>
then, just follow those instructions, creating a new entry in the Developer Console.
if you hit your app maps prior seeing the log, you may need to close app from memory and try again)
this procedure should work on an emulator too.
If you are created SHA1 code from custom keystore use the same in release mode. or generate apk by signing with that same keystore and test.
Before that you need clear app data (Setting->App-select app-Clear data->uninstall) and try. this worked for me.
Ensure that package name is same as that in google developer console.
I had a similar problem: after creating a couple of new variants builds with same type ("release") but some new flavors ("free" and "premium"), the Google Maps fragment did not show anymore the maps and the screen appeared totally blank. In the logcat I could only see next error message "Unexpected response code 400 for https://clients4.google.com/glm/mmap/api" that probably was indicating some problem with the Google Maps API access.
Of course I reviewed again all the Google Cloud API process in order to check if something was missing in my API key credentials, but I did not find anything wrong. In fact, for new APK's it is indicated to add the builds info (name+fingerprint) to the existing Project Credentials in order to inherit the same API key that is still valid.
The instructions that we can read are very clear: "Add your package name and SHA-1 signing-certificate fingerprint to restrict usage to your Android apps. Get the package name from your AndroidManifest.xml file. Then use the following command to get the fingerprint: keytool -list -v -keystore mystore.keystore".
The problem in my case was that my new variants "package names" were not the one existing in the Manifest package name ("com.example.app_name.release"). In fact, due to my new flavors I had the same Manifest name BUT two new "real" package names: "com.example.app_name.free.release" and "com.example.app_name.premium.release". Those names do not appear written in the Manifest file as such as they correspond to the Gradle configuration where flavors are defined (in my case with "applicationIdSuffix" attribute). This is quite confusing for me as Gradle "application id" should not overlap the Manifest "package name". But when we read carefully all the Android documentation, we can read "if manifest package name is different than Gradle applicationId, build will copy the application ID in final manifest file". Of course, both variants have the same fingerprint as both are still of the same build type ("release").
So the solution was to add in the same Project Credentials the two new variant entries to inherit the same API key:
original entry (don't need to delete it): Package name = "com.example.app_name.release" - SHA-1 certificate fingerprint = "xxxxx"
new entry 1: Package name = "com.example.app_name.free.release" - SHA-1 certificate fingerprint = "xxxxx" no change, same as used until now
new entry 2: Package name = "com.example.app_name.premium.release" - SHA-1 certificate fingerprint = "xxxxx" no change, same as used until now
Finally, it may be needed to clean your build in order to ensure that you are really watching the correct updated behavior in your maps fragment or activity.
About the rest of recommendations, in my case I did not have to apply them:
- no need to hardcode the API key in the Manifest
- no need to create a new API key for the new variants APK's
- no need to use the google_maps_api.xml files
Below method worked for me:
Put google maps api key in manifest as hardcoded text mentioned by #Florence Herrou
Android Studio creates inside:
app\src\debug\res\values\google_maps_api.xml (debug) //add key here
Add key inside ->
app\src\release\res\values\google_maps_api.xml (release) //add key here
Google key has two types of Security.
1.Non restricted key
2.Restricted key (Android restricted through SHA-1)
Note: Use Restricted key for Maps,Places, but not for Google Directions. use Non restricted api key for google Directions . bcz its web based api response so restricted key doesnt work.
-> When using Non Restricted key
look into 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. make sure key is same in both files.
-> When usingRestricted (Android SHA-1) key
Step - 1 : look into 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. make sure key is same in both files.
Step - 2 : Generate SHA-1 using AndroidStudio (gradle tab in Left Pane and select signing Report) and add as a item in google Developer console for the Api key which your using.
Step - 3: As soon as you generated Signed Apk google will overwrite your Androidstudio generated SHA-1 a with google own SHA-1 key. so u need to get tht also to be added for Api key in Api key in Developer console
Goto Release Management -> App Signing -> and copy the SHA-1 certificate fingerprint from App signing certificate
Paste this newly copied SHA-1 fingerprint to Developer Console and map in release mode will show.
Step 4: Add Release build SHA-1 also to Api key in Developer console like below.
Goto Release Management -> App Signing -> and copy the SHA-1 certificate fingerprint from Upload certificate
Paste this newly copied SHA-1 fingerprint to Developer Console and map in release mode will show.