Android Google Services: API key and SHA-1 fingerprint for release and debug

只谈情不闲聊 提交于 2019-12-13 03:02:19

问题


I was able to build a release-apk successfully in android studios.

My app uses some services from Google like Google App Invites and Google Places for Android.

To get these services, I had to register a API key on the google developers console which looks like this:

I'm unsure about the package name and SHA-1 fingerprint section of getting an API key.

If I have both a debug and a release version of my app (let's say the package name is com.myapp), do I put in the com.myapp as the package name twice but set the release and debug SHA-1 respectively for each package name?

So:

com.myapp (SHA-1 fingerprint) S1:2D:3F etc
com.myapp (SHA-1 fingerprint) D2:1W:2V etc

I tried to do that but so far the release version of the app does not seem to want to work at all.

APP_INVITE says:

No Android client ID is found for package name com.myapp. (APPINVITE_CLIENT_ID_ERROR)

PLACES AUTOCOMPLETE says:

Error getting autocomplete prediction API call: Status{statusCode=PLACES_API_INVALID_APP, resolution=null}


回答1:


It's a little bit confusing, I think the best solution to get rid of such scenarios is to add an applicationIdSuffix so you (and any other service) could distinguish between builds: com.myapp.beta for build and com.myapp for release.

I'd recommend you to take a look at this detailed tutorial: http://medyo.github.io/2015/different-android-app-resources-gradle-build-type/

Hope that answers your question




回答2:


OK - after some investigations, yes, you do put your package name twice and then you put the SHA-1 fingerprint for the release and debug version separately. This will make PLACES work.

Also, from my investigations, I noticed that the APP_INVITE error pointed to no client ID found for the package. Please note that this is referring to your OAuth 2.0 client IDs which can be found under your API keys in your Google Developer Console. Changing that SHA-1 key (there is no option to put in a development SHA-1 and a debud SHA-1in this case) will result in APP_INVITE working.



来源:https://stackoverflow.com/questions/36118008/android-google-services-api-key-and-sha-1-fingerprint-for-release-and-debug

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