I am trying Google Place Autocomplete Example from https://github.com/googlesamples/android-play-places.
I have put the correct API key at the correct place. I knew it because when I put a random string invalid API key I will get a different error.
So after I put the correct API key, I run the app in both real device and simulator. Both devices gave me this error:
What causes this error and how to fix it?
It’s because the package that you put on the credentials section on the Developers Console is different to the project you are building.
- Open https://console.developers.google.com
- Go to APIs & auth menu on the left side, and go to Credentials
- You can add new Android API and put the package you are building, or edit any existing and add another package name and fingerprint (SHA1).
I was getting the ‘PLACES_API_INVALID_APP’ even after posting my release SHA1. After trying everything I found out my release app was not even signed with the SHA1 I was getting from the keystore. So I did this:
1.Go to google play console
2.Release Management > App Signing > App signing certificate
3.Copy the SHA1 of App signing certificate and paste in google api console’s credential page
Now you are good to go! Sadly it is not documented anywhere currently.
Follow my steps:
1> Creating one new projects on Google Developer Console
2> API Manager > Credentials > New Credentials > API Key > Android Key > Press Create Button & Generate API KEY
Here, Creating key without applying package of application & SHA fingerprint is working in any application
Enable Google Places API for Android
In my case
SHA-1 certificate fingerprint was for
debug build only, I added
release SHA-1 key also. Now it’s working.
Make sure you use the exact packageName and valid SHA-1
key for debug as well as release app
it means your api key invalid so create API key with your Package name and SHA Fingerprint
STEPS fot Creating API KEY
1.Get information about your app’s certificate (SHA fingerprient).
2.Register a project in the Google Developers Console
3.Add the Google Places API as a service for the project, and create an API key.
4.Add the key to your app manifest.
Although I have enable Android Place API from developer console but i came across this error:
Then I go to developer console and select my project registered earlier, and follow the option of “Get Place API key” for my project.
I resolved it this way.
I was seeing this error in the Google Play Console pre-launch report, despite having added the Google Play App Signing SHA-1 certificate.
Turns out there is an option in the pre-launch report’s settings menu called pre-launch report version, which says:
Pre-launch report now explores your app even more deeply and may find
more crashes. However, in order to do so, it will temporarily re-sign
your APK within our lab environment.
I’ve enabled the option to opt-out of pre-launch reports where the app is re-signed, and the error has gone away.
Click on your application > Release management > Pre-launch report > Settings > Pre-launch report version.
This won’t help you fix the error on a real device, but it fixed my issue.
Credit to this answer for pointing me towards this.
Make sure that you have the API meta-data placed in Manifest.xml file
<meta-data android:name="com.google.android.geo.API_KEY" android:value="You API Key Here"/>