Maps Android API: Authorization failure - android

There are many questions similar to mine. i went over them all (i hope). Also i think i'm doing everything OK. Maps v2 worked until last update of Google Services to Rev 25
I'm getting:
E/Google Maps Android API﹕ Authorization failure
Ensure that the "Google Maps Android API v2" is enabled.
Ensure that the following Android Key exists:
API Key: AIzaSyB...
Key matches. next:
Android Application (<cert_fingerprint>;<package_name>): 87:60:41:37...;com.example.example
Certificate match
So everything matches but i still getting Authorization failure
AndroidManifest
<meta-data
android:name="com.google.android.gms.version"
android:value="7571000" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="#string/google_maps_key" />
gradle-app:
dependencies {
compile 'com.google.android.gms:play-services-location:7.5.0'
compile 'com.google.android.gms:play-services-maps:7.5.0'
compile 'com.google.android.gms:play-services-gcm:7.5.0'
}
Also i recompiled and re-installed the app multiple times

Delete older key and generate new key. Hope it helps!!
The answer is only based on comment.

Related

GooglePlayServicesIncorrectManifestValueException when checking if play services are available

We are using GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context) to check for google services before showing a map. Even though the device has access to play services, the method is throwing an exception when being called. The exception is GooglePlayServicesIncorrectManifestValueException with the message:
“The meta-data tag in your app's AndroidManifest.xml does not have the right value.
Expected 12451000 but found 4323000. You must have the following declaration within the
<application> element:
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />”
In the manifest I’ve declared:
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
If I go into the play services version, I get:
<integer name="google_play_services_version">12451000</integer>
Which comes from
jetified-play-services-basement-18.1.0/res/values/values.xml
I’ve tried most solutions in other stack overflow posts to no avail. These are all the things I’ve tried and none of them work:
Change tag order in manifest (https://stackoverflow.com/a/37810158/8575762). This has no effect, and also it makes no sense that it should have one.
Make sure we are not providing our own hardcoded version (https://stackoverflow.com/a/63791222/8575762)
Remove the <meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" /> tag from the manifest.
Update firebase libraries to latest BOM version (30.5.0)
Remove firebase libraries completely.
Update play services dependencies to latest version(auth, auth-api-phone, vision, wallet, location, safetynet)
Update google services plugin to latest version (4.3.13)
Add tools:node="replace" (also tried other manifest options like node:replace, etc) to the metadata tag & hardcode the version value
If I inspect the AndroidManifest on the built apk (debug), the value of the meta-data tag is the following:
<meta-data
android:name="com.google.android.gms.version"
android:value="#ref/0x7f0b000f" />”.
It’s important to note that this behavior is not 100% consistent. Usually I’ll do a fresh install and the first time I launch the app the isGooglePlayServicesAvailable method returns without crashing. If I restart the app it no longer works.
This seems like a bug in the services implementation library to me, but it feels like something too simple to be failing like that.
Any help would be appreciated, thanks in advance.

Google Maps Android API: Authorization failure - kotlin

I have created a demo from here : https://github.com/suchoX/PlacePicker
Done same as explained over there.
Added Api key also in my Manifest file as below inside application tag:
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="secret_api_key_not_shown"/>
Getting below error :
E/Google Maps Android API: Authorization failure. Please see https://developers.google.com/maps/documentation/android-api/start for how to correctly set up the map.
12-05 16:22:30.108 10392-10522/com.mypackage 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.
You need to enable the "Maps SDK for Android" API from the Developer Console.

How to use maps v2 api key without app package restricctions?

Now, when you register an api key on api console for using Maps V2 on Android, you can configure it to work without restrictions, and I want to do it because I want to make some tests with the same key in various apps, and it's mandatory for me to achieve this.
I configured the key this way:
But when I'm trying to use it without restrictions active on the api key configuration, in debug mode it works perfectly but after signing my app with my keystore the tiles on the map are not being displayed and I'm getting this error on the logcat:
Google Maps Android API: Authorization failure. Please see https://developers.google.com/maps/documentation/android-api/start for how to correctly set up the map.
03-02 16:49:12.158 2600-2660/? 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: YOUR_KEY_HERE
Android Application (<cert_fingerprint>;<package_name>):
What more it's necessary to do to get a key working without restrictions in various apps without indicating theirs packages and sha's ?
PD: I don't know why API Key has a "YOUR_KEY_HERE" value on the log because it's correctly specified on the xml file and I can see it on the manifest.
Finally the solution was very simple, but frustrating. In Android studio you can see this file for editing:
app > src > debug > res > values > google_maps_api.xml
And it's the debug placeholder for the key... you must also write your key here manually:
app > src > relese > res > values > google_maps_api.xml
Worked like a charm.

Android Admob implementation: Get the error : "Google Play Services resources were not found"

I tried to upgrade my implementation of AdMob. Using the GoogleAdMobSDK, I would like to turn into the google-play-services-lib.
The ad appears. So it seems ok, but I still got this error at the method call loadAd() in log
Requesting resource 0x7f0c000d failed because it is complex
GooglePlayServicesUtil: The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
Here's my checklist:
I import the library project in my workspace, copying the source.
I reference the library into my project
I add the meta-data in the Manifest
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
My code
this.request = new AdRequest.Builder().addTestDevice(id).build();
this.adView = new AdView(context);
this.adView.setAdUnitId(MY_AD_UNIT_ID);
this.adView.setAdSize(AdSize.SMART_BANNER);
...
this.adView.loadAd(request);
The target version for my app in 9 (2.3). I test on Nexus 5 with KitKat version.
I also tried to put the google-play-services-lib jar in the properties, but no result.
I want to be sure that this error could be handle before submit my app.
This is a benign error with the current version of Google Play Services.
Don't worry about it. Submit your app. Get some sleep.

Can't connect to Google Maps Api Android V2

I created a small Android Map project and everything went fine until I move with my workspace to another computer.
The google map is not visible and the logcat output has the following line:
07-24 16:15:24.261: E/Google Maps Android API(21868): Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors)
My first thought was the missing/wrong keystore because I forgot to copy it from one computer to the other, so I took the SHA1 fingerprint from my new debug.keystore (C:\Users\Enrico.android) and created a new Api key with this fingerprint and put it to Manifest.xml.
No result.
My second action was to renew the google-play-services_lib but it changed nothing.
Here some interesting parts of my code and from the Api console:
SHA1:
C1:07:A9:8B:E0:B1:FF:49:B4:C3:C6:E8:3B:98:93:FF:8F:D6:36:2F
Api console:
API key:
AIzaSyDaDJBQyg7I8_Bd3IrKChEdcNo2E7cxU6g
Android apps:
C1:07:A9:8B:E0:B1:FF:49:B4:C3:C6:E8:3B:98:93:FF:8F:D6:36:2F;com.name.appname
Manifest.xml:
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyDaDJBQyg7I8_Bd3IrKChEdcNo2E7cxU6g"/>
<uses-library android:name="com.google.android.maps" />
Please help me!!!
EDIT:
Another hint. When I first started my App on the new computer, I needed to remove my "old" version from my testphone with the hint, that the signature has changed. So in fact it can only be the wrong SHA1 fingerprint in the debug.keystore file...or?
After you have updated SHA-1 on the API Console, you may need to uninstall and install again the app.
Seems like Google Play Services is keeping "unauthorized" answer from the server in cache.
Edit:
You can try creating another API key without specifying SHA and package name. This will create a key that says "Android apps: Any app allowed". I'm a bit concerned about such possibility, because that key could be used by anyone in their apps, but for development it is not an issue.
You might have forgotten to add add the permission "MAPS_RECEIVE"
Define this permission:
<permission
android:name="com.jonasdevlieghere.alma.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
and add it to the list of necessary permissions:
<uses-permission android:name="com.jonasdevlieghere.alma.permission.MAPS_RECEIVE" />
Feel free to change the permission name to match your own application.

Categories

Resources