Moving Maps API project to a different development

2019-08-03 03:08发布

问题:

I am writing an App in Android 5.1 with Android Studio that uses the Google Maps API v2. I copied the all the project's files and moved them to a new computer. Then I did a build from the new computer and installed the App on a phone. There were no problems with the build and install.

But I get a runtime error and plain grey rectangle where the map should be.

08-09 20:52:39.947 14052-14183/cetlot.com.sisuyouth E/b﹕ Authentication failed >on the server. 08-09 20:52:39.947 14052-14183/cetlot.com.sisuyouth E/Google Maps Android API﹕ Authorization failure.
Please see https://developers.google.com/maps/documentation/android/start for how to correctly set up the map. 08-09 20:52:39.956 14052-14183/cetlot.com.sisuyouth 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: AIzaSyCR2CMntoLW8xubFsYMpENSdKoWUcyKG2w Android Application (;): 39:45:E7:0B:45:8B:17:0D:56:98:B4:D3:28:9C:16:41:46:65:71:20;cetlot.com.sisuyouth

Do I need a new API key for the new computer? And will the certificate fingerprint in the error message work for that purpose? I am having trouble with the keytool utility on this computer.

回答1:

Nope. It turns out I don't need a new key for the new computer. All that is needed is to add this certificate fingerprint from the new computer to the 'Allowed Android Applications" under Credentials in the Google Developer console.

And it works!



回答2:

It seems you need to add/Verify SHA1 key obtained from your keystore file. If you are using debug.keystore file then from JDK --> BIN folder

keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android 

and verify if generated key mactches to the SHA1 you added to Google API Console