google map authenticate failed, after package name changed

余生长醉 提交于 2019-12-11 11:45:43

问题


I have an android app with a Google map, everything works good.

In order to publish it in Google play, I changed the package name (old package com.exmaple..) from project----- Android tools---Rename Application Package

So, I going to generate a new API key with my new package name.

I changed manifest with the new key.

     <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="xxxxxxxxxxxxnew keyxxxxxxxxxxxxx" />

But, it did not work. It said authentication failed. Is there any idea? Did I miss some steps?

Thanks in advance!


回答1:


If you are saying that you have generated the new key using the API Console and changed the API key in your application as well as changed the package name in those two permissions:

<permission android:name="your.application.package.permission.MAPS_RECEIVE"  
            android:protectionLevel="signature"/>
<uses-permission android:name="your.application.package.permission.MAPS_RECEIVE"/>

Then try to remove your application complete from the phone, as application is usually saves the old key in the cache, and then try to re-install it.




回答2:


As you have renamed your package name and Google API key is generated based on the Package name and SHA1 key to uniquely identify each application. You need to regenerate your API key and then try to apply it in your manifest file.




回答3:


Please check out the documentation

To access the Google Maps servers with the Maps API, you have to add a Maps API key to your application. The key is free, you can use it with any of your applications that call the Maps API, and it supports an unlimited number of users. You obtain a Maps API key from the Google APIs Console by providing your application's signing certificate and its package name. Add the key to your application by adding an element to your application's AndroidManifest.xml file.

You changed your package name so google map authentication is failed. Please regenerate new key with your new package name.




回答4:


Addition to the answer before.

Make sure signing API key by the release keystore instead of debug.keystore




回答5:


If you checked and found that the package name is configured correctly in Google API, go over the below steps

  1. Make sure that there is no reference in your project to the old package name. I changed it in the manifest file but forgot to change it in the build.gradle file
  2. Delete the .gradle folder in your project cause gradle might have cashed the old package name
  3. Ctrl+Shift+F to look for the old package name in the entire project.Make sure there is no trace of it
  4. Uninstall the app on your testing device to clear any cached data
  5. Clean project and then run it

Those steps did it for me.



来源:https://stackoverflow.com/questions/20042863/google-map-authenticate-failed-after-package-name-changed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!