I am working on google maps and I am getting this error. I had done the following things:
Got My sha1 fingerprint.
Registered my project and
you may need to add new SHA-1 Certificate fingerprints to your API key application restrictions page:
to generate a SHA1 Certificate fingerprints for your debug build, use keytool of java jre as the following example command:
C:\Program Files\Android\Android Studio\jre\bin>keytool -list -v -keystore C:\Users\linhd\.android\debug.keystore -alias androiddebugkey -storepass android -keypass android
For anyone else that sees this as I did even though everything was setup, ensure you are in the correct project. These have to be done per project.
This may happen when the package name is incorrect in the console credential section for development and production make sure your package name is correct. In my case, the package name was wrong when I corrected it map become visible
I had the same problem, but in the following setup:
My actual developing took place on a Windows machine. Then I bought a Mac and figured I'd develop on it. I installed Android Studio on my Mac, checked out my project from Github, then attempted a run of it using my Android phone. The APK installation carried out seamlessly. However, once the application launched on the phone, the GoogleMap wouldn't display, even though the rest of my app was functioning normally. Then I found this link => https://github.com/react-community/react-native-maps/issues/69, went to my console.developers.google.com/ and opened my Google Maps key that I had issue with.
What I saw was that the key was restricted to Android apps. But I was working on an Android app, how could this be the issue? Anyhow, I switched Key Restriction to None, reran my app, and GoogleMap loaded just as it should had.
Make sure Maps SDK for Android
is enabled in API console.
Also you might need to add your package name and SHA-1 signing-certificate fingerprint to restrict usage for your key to be fully enabled.
I added a key from another test project to a main. Then I opened https://console.developers.google.com/ and added that key with a new application name (like Linh Dao wrote), but it didn't help.
Then I added a new activity (a template "Google Maps Activity" in a gallery) and opened a file google_maps_api.xml
. From there I again found a link like https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r=06:F2:F4:CD...applicationName.
I opened app/build.gradle
, found applicationId
value with applicationIdSuffix
, if exists, and joined, for instance into com.example.myapp.debug
. In the link I changed an applicationName to this new value and opened the link.
Again created a new project, generated a new key and edited it, wrote package name and SHA-1 fingerprint, like @Linh Dao wrote. Then saved. If you later with to find that key, find your project in Google console and open credentials.
I deleted an unnecessary map activity and in AndroidManifest
retained
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />
in application
tag.
UPDATE
After several months I got the same exception in debug
build. As I understood, I set wrong API key.
In LogCat I saw this exception:
Then I opened https://console.developers.google.com/, a needed project was opened, clicked on "Maps SDK for Android".
Turn to "Credentials" tab (you can also see https://developers.google.com/maps/documentation/android-sdk/signup for information). Click your API Key.
On the API key
page, under Key restrictions
, set the Application restrictions
. Click + Add package name and fingerprint
.
Enter your package name from LogCat above (for example, com.your_package.debug). Enter your fingerprint from LogCat (91:D6:...:F7). Save it.
As @Ahamed Rasheed wrote, I invalidated caches, cleaned and rebuilt the project.