1

I am currently developing an android application with google maps as a fragment when i test it and run it on the android studio using an actual device connected via usb on my laptop the google maps fragments works fine but when i build an apk file and install it on the android device the google maps is not working i cannot see the maps but the app is not crashing

what is wrong in my project?

4 Answers4

0

You are using your local system specific API_KEY(having SHA_KEY of your local system) for maps, Create a new API_KEY using SHA_KEY which you had used to generate the certificate of your Application. That will be your production API_KEY.

Ankit
  • 101
  • 5
0

While building your application and installing it directly from studio, studio will use the debug key.But while releasing the app, the apk has to be signed with release key instead of debug key.The Android SDK tools generate this release certificate when you do a release build.

So for generating the map key, if you are in development phase, you can use debug key to generate map key. But when you release the app, you have to obtain new map key using the release key and replace that in your manifest file.

Regarding signing your app, refer this link.

Your application needs an API key to access the Google Maps servers. The type of key you need is a Key for Android applications. The key is free. You can use it with any of your applications that call the Google Maps Android API v2, and it supports an unlimited number of users.

Choose one of the following ways to get your API key:

The fast, easy way: Use the link provided in the google_maps_api.xml file that Android Studio created for you:

Copy the link provided in the google_maps_api.xml file and paste it into your browser. The link takes you to the Google Developers Console and supplies information via URL parameters, thus reducing the manual input required from you.

Follow the instructions to create a new project on the console or select an existing project.

Create an Android API key for your console project.

Copy the resulting API key, go back to Android Studio, and paste the API key into the element in the google_maps_api.xml file.

A slightly less fast way: Use the credentials provided in the google_maps_api.xml file that Android Studio created for you:

Copy the credentials provided in the google_maps_api.xml file.

Go to the Google Developers Console in your browser.

Use the copied credentials to add your app to an existing API key or to create a new API key. For more details, see the complete process.

The full process for getting an API key: If neither of the above options works for your situation, follow the complete process.

Refer this link for more details

Renjith
  • 3,274
  • 19
  • 39
0

To create Released Key, you need to generate keystore first. After that you need to generate new SHA1 Key using that keystore.

C:\Program Files\Java\jdk1.7.0_75\bin>keytool -list -v -keystore C:\Users\shvet\ Downloads\keytool -alias android -storepass keystorename -keypass androidpass

where C:\Users\shvet\ Downloads\keytool is my keystore path.

-alias android is alias name when i made keystore while generating apk.

-storepass keystorename is name of keystore password.

-keypass androidpass is password for SHA1.

Image

Use this SHA1 key to generate new Google map Key.

Shvet
  • 1,159
  • 1
  • 18
  • 30
0

Make sure that billing is enabled for your Cloud project. Confirm here that billing is enabled for your project: https://console.cloud.google.com/projectselector2/billing

and also you need to add sha1 release code to your api key, in google cloud platform.
google cloud platform

just add an item under the " Restrict usage to your Android apps" title. there you will need your package name , which you used before, in the debug item (which has its own sha1 code) , and the release sha1 code, which you might need to search how to get it . here is a good link for it.

Gilad Levinson
  • 234
  • 2
  • 12