I am uploading an APP to Play Store. It is being uploaded well but there is one inconvenience, the maps that I am using is showing on debug mode but not when I use my application on production (when I upload the APP to the market and download it from there). A grey screen is shown when I try to open the map. I am using Google Maps.
What I have done:
I have created a release profile to sign my APK that I use when I generate my APK. To sign the APK I do (on Android Studio) Build > Generate Signed APK with the Name, Alias and Password of my certificate profile.
I have generated a Google Maps API credential using SHA-1 of the certificate that I have created in the step before and the name of the package of my project. I have restricted it to only be allowed on Android. It have generated a key to me.
I have added these two lines on AndroidManifest.xml file of my project:
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="#string/google_maps_key" />
where #string/google_maps_key is the key that I have obtained in the second step and that I have stored in strings.xml file.
I know that there are some questions related in Stackoverflow but most of them suggest generate one of both certificates that I have already created.
Am I missing some requirement? Should I change some configuration?
Thanks in advance!
When you generated your Google maps key, did you put SHA-1 of your debug, or of your release certificate? If you put debug SHA-1, add release also.
Update:
Also, proper way to do map implementation would be to have debug/res/values/google_maps_api.xml with key for debug and another release/res/values/google_maps_api.xml with key for production. There shouldn't be key in strings.xml. More about this you can read here.
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'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 .
I have a problem with Google Maps api v2 on my android app.
I have generated the key for the debug certificate and everything works fine, but I can't make it work with the release certificate.
I've generated the key and the alias with eclipse, then I took the SHA1 which eclipse shows at the end of the "Export signed application" process.
Then I generated the api key for android apps in my google api console using
SHA1;package name
But it doesn't work... it works only with the debug key generated in the same way, only using the sha1 of the debug certificate!
Please help me, otherwise I can't release my app
Check your manifest file, I guess you've forgotten to set your release map api key there while exporting with your release key?
Me too faced the same problem during releasing my app to google Play, when I used Google Maps V2 in my app. After succeeding the issue, I wrote a blog post regarding this you can have a look.
As everyone requested, I would say the answer in following steps
1) Sign up your app using eclipse adt
2) Note down the SHA1 finger print which will be displayed at console of your eclipse adt
3) Again go to google console and get API_KEY for your app by using above got SHA1 fingerprint
4) Replace the old API_KEY with the new API_KEY on to manifest.xml of your app
5) Again sign up your app. Your app is ready to be published. But keep in mind that once you published your app to google market, you should be able to release updates to your app by signing .apk using the keystore which you used earlier for release.
Hope this helps ...
There are two files google maps api.xml, one is the debug and release the other, then you should replace the key generated on google website console and enter this file, another outlet is inserted directly into the manifest.