Android Maps API2 release key working locally but

2019-07-20 22:09发布

问题:

I am making an app that uses the Google Maps API V2. When building the App in debug mode, using the debug key the map gets displayed fine. The same is true, when I export the app using Eclipses export function and my production key, installing the app locally with:

adb install com.package.name

However when I publish the apk in the Play Store (as an alpha test) and download it on my device, no map is displayed, making me suspect that something goes wrong with the key.

I registered the production key in the API console and changed the maps key in the manifest to the new key, hence it works when I install it through ADB.

I also uninstalled the app, before the reinstallation from the Play Store and removed my debug key from the API console, to make sure that the release key gets used (and thereby is working correctly).

Any help would be greatly appreciated.

回答1:

This is a late response, but I thought it might help others who might run into this similar problem. I too had all my release/debug keys generated correctly and the maps on my signed release apk works well through ADB install, but not after uploading to Google Play Store.

Here is my solution: With the new optional "Google Play App Signing" feature, your final SHA1 can be found in your Google Play Console -> Release Management -> App Signing. Add the SHA1 for the app signing certificate to your key restriction list for the API in your API console and your map should be working.

Apparently the generated SHA1 using my own keystore (release) prior to uploading, is different from the final one, after uploading into Google Play Store.

Hope this helps.



回答2:

Go to the google Apis console and add one more entry with your debug key.

So then you will have an entry :

45:B5:E4:6F:36:AD:0A:98:94:B4:02:66:2B:-- blah blah production key;com.package.name 45:B5:E4:6F:36:AD:0A:98:94:B4:02:66:2B:--yada yada debug key;com.package.name

//The keys I used are random you will get them both running the following command for each keystore ( debug and production )

Use this command to get the key :

keytool -list -v -keystore mystore.keystore

tl;dr two keys one for debug one for production and two entries to the Google Api Console



回答3:

I fixed the problem by creating a new app and a new certificate. I don't consider this a "solution" since I did not find out what went wrong in the first place.



回答4:

Basically whenever in the case of Google Map, we need an API key, which is generated on the basis of SH1 key of keystore. When you work on local system, then we have to use the SH1 key which is displayed in Eclipse. But when we sign our application to make an APK to upload on playstore, we need to edit the exiting key and replace the old SH1 key with a newer SH1 key. Note: You can get the newer SH1, while signing the APK for playstore. While signing it display the SH1 key of of keystore file, which you are using for that particular application for Playstore.