Failed to load map. Error contacting Google servers. This is probably an authentication issue
it sounds like you have problem with your API_KEY
which is obtained from Google API Access ,so verify your API_KEY
, certificate fingerprints and package name
also use this inside <manifest>
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" >
</uses-feature>
and also verify: <meta-data .... >
should be inside <application>
tag
PS.
1. Also try by adding following Permission
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
2. After changing API key
in AndroidManifest.xml
Must Clear Application Data
To Clear Application Data :
Either Go to Settings>Application Manager>Select Your Application > Click on Clear Data
Or Must Uninstall The Application
before installing it !
Note Don't Re-install
unless you Completely Uninstall the Application
in order to clear its Data completely
Failed to load map. Error contacting Google servers issue with android google maps api v2
Found it after all, after turning off WiFi on the device I was using. It seems that when debugging over WiFi you also need the
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
in the manifest. Don't know if it was just my case or it's a general thing, but I guess it should be in the documentation somewhere (it's not).
So if you are reading this and having similar problems try either disabling WiFi or adding the above permission alongside the others.
GoogleMap V2 Failed to load map.Error contacting Google servers
I solved these problem by doing the following steps:
In Emulator:
You have to use the latest API
Google APIs(Google Inc.)-API Level
.
19Do the rest of the things placed in the screenshot itself.
API Key:
Create New API Key and Check carefully about Google Map API key and SHA Key.
Google Play Services:
You have to download the latest Google Play Services
com.android.vending-4.8.20.apk.In that site if google play
services wasn't working means you can find a lot of sites in
internet namedcom.android.vending 4.8.20.apk
.you can run the Google play Services by using the Command Prompt
adb install com.android.vending 4.8.20.apk
.Note: You have to download the latest Google play services because year by year latest version will be updated in internet.
output:
Android Google Map: Failed to load map. Error contacting Google servers
I would try generating a new API key using the SHA1 from the debug keystore in the .android directory; it is called debug.keystore and should be located in the following directory:
- OS X and Linux:
~/.android/
- Windows Vista and Windows 7:
C:\Users\your_user_name\.android\
Once you locate it you can get the SHA1 with the following command:
OS X and Linux:
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android
Windows Vista and Windows 7:
keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android
Failed to load map. Error contacting Google servers. problems with 1 pc
This is an API-KEY
authentication issue.
You need to get your SHA1 for this pc and put it in your Google developer console
project. Or re-generate a new API key.
For more details, how to do it, please refer here.
Google Maps not showing in my app , and appear in another app
I just tested your code and it works without problem on my end using an emulator. All I changed was setting the activity as launcher and removing the third-party dependencies.
Please test the below code, which is basically your own code without dependencies:
MapActivity
public class MapActivity extends FragmentActivity implements OnMapReadyCallback {
static final LatLng HAMBURG = new LatLng(53.558, 9.927);
static final LatLng KIEL = new LatLng(53.551, 9.993);
private GoogleMap map;
Button select;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
select = (Button) findViewById(R.id.select);
select.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent();
setResult(RESULT_OK, intent);
finish();
}
});
}
@Override
public void onMapReady(GoogleMap googleMap) {
map = googleMap;
map.addMarker(new MarkerOptions().position(HAMBURG).title("Marker in Delhi"));
map.moveCamera(CameraUpdateFactory.newLatLng(HAMBURG));
}
}
activity_map.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MapActivity">
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<Button
android:id="@+id/select"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.551"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0"></Button>
</androidx.constraintlayout.widget.ConstraintLayout>
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.myapplication"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'com.android.volley:volley:1.1.0'
implementation 'de.hdodenhof:circleimageview:2.1.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.karumi:dexter:5.0.0'
implementation 'com.google.firebase:firebase-messaging:17.3.3'
implementation 'com.google.android.gms:play-services-auth-api-phone:17.0.0'
implementation 'com.google.android.gms:play-services-auth:17.0.0'
implementation 'com.google.android.gms:play-services-base:17.0.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.mxn.soul:flowingdrawer-core:2.1.0'
implementation 'com.nineoldandroids:library:2.4.0'
implementation 'com.flaviofaria:kenburnsview:1.0.7'
implementation 'com.wang.avi:library:2.1.3'
}
manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dist="http://schemas.android.com/apk/distribution"
package="com.example.myapplication"
android:versionCode="30"
android:versionName="1.2.9">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<dist:module dist:instant="true" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />
<activity
android:name=".MapActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
If the above code works for you then you can rule out network-related or emulator/device-related issues (if it doesn't then please look into those).
Thereby the root cause is either those library dependencies I removed or your API key. Make sure that you added your unrestricted API key to your google_maps_api.xml files (in both debug and release folders), that Maps SDK for Android is enabled on your project and that your billing account is in good standing.
Hope this helps you!
Authorization failed. Failed to load map. Could not contact Google servers. (Google Map for Android)
Okay, so I have been doing it correctly. It's just that I've been compiling it to a 3.2 android device instead of a 4.0 device, and now it works! I just don't understand the reason why 3.2 version with API level 15 won't give result when my targetSdkVersion is 17?
Related Topics
Bitmapfactory Oom Driving Me Nuts
Finish an Activity from Another Activity
Unable Instantiate Android.Gms.Maps.Mapfragment
How to Disable Action Bar Permanently
Changing Screen Brightness Programmatically (As with the Power Widget)
Nullpointerexception:Println Needs a Message in Android
How to Deploy and Execute an Application on a Device Connected to a Remote System
Pass a String from One Activity to Another Activity in Android
How to Kill an Application with All Its Activities
Passing Arraylist of Objects Between Activities
Play Audio File from the Assets Directory
How to Show Dependencies Tree in Android Studio
Custom Filtering in Android Using Arrayadapter
How to Prevent Multiple Instances of an Activity When It Is Launched with Different Intents
How to Find and Run the Keytool
How to Disable Scrolling on a Viewpager
Error:Execution Failed for Task ':Android:Transformclassesandresourceswithproguardforrelease'