Reputation: 537
I want to generate and use a google API key.
Then:
Upvotes: 42
Views: 71494
Reputation: 4324
Please follow these steps:
Upvotes: 0
Reputation: 2258
Make sure you enable the Maps for Android app in Google Console.
Upvotes: 1
Reputation: 7701
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:
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.
Upvotes: 2
Reputation: 592
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 sign application in debug mode to get sha1
Upvotes: 1
Reputation: 2305
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
Upvotes: 3
Reputation: 317
I faced the same problem, in my case fingerprint of my package used in google map API key was mismatched so what i did:
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
Upvotes: 0
Reputation: 309
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.
Upvotes: 0
Reputation: 4330
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.
Upvotes: 13
Reputation: 2281
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.
Upvotes: 0
Reputation: 43322
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.
Upvotes: 85