本文介绍了Google Maps Android授权失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
因此,我查看了有关此问题的许多问题,但未能找到解决方案.
So I've looked over many questions on this issue but have failed to find a solution.
以下是我尝试使用Google Maps Android API时收到的错误.
Following is the error I'm currently receiving when I try to use the Google Maps Android API.
02-28 11:17:07.166 7445-7653/com.test.drawernav E/b: Authentication failed on the server.
02-28 11:17:07.166 7445-7653/com.test.drawernav E/Google Maps Android API: Authorization failure. Please see https://developers.google.com/maps/documentation/android/start for how to correctly set up the map.
02-28 11:17:07.176 7445-7653/com.test.drawernav 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: ***
Android Application (<cert_fingerprint>;<package_name>): ***
这是我的清单文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test.drawernav">
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<uses-permission android:name="com.example.googlemaps.permission.MAPS_RECEIVE" />
<permission
android:name="com.example.googlemaps.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="@mipmap/logo"
android:label="Animal Rescue"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".SplashScreen"
android:label="@string/title_activity_splash_screen"
android:theme="@style/AppTheme.NoActionBar"
android:configChanges="keyboardHidden|orientation|screenSize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="portrait" />
<activity android:name=".SAC" />
<activity android:name=".FAD" />
<activity android:name=".HAM" />
<activity android:name=".BAB">
</activity>
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="***"/>
</application>
</manifest>
这是地图的Fragment.java
Here's the Fragment.java for the map
package com.test.drawernav;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
/**
* A simple {@link Fragment} subclass.
*/
public class LocateFragment extends Fragment implements OnMapReadyCallback {
public LocateFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View mapView = inflater.inflate(R.layout.fragment_locate, container, false);
return mapView;
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
SupportMapFragment mapFragment = (SupportMapFragment)getChildFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
@Override
public void onMapReady(GoogleMap googleMap) {
}
}
和相同的layout.xml
and the layout.xml for the same
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.test.drawernav.LocateFragment">
<fragment
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/map"
class="com.google.android.gms.maps.SupportMapFragment"/>
</FrameLayout>
这是显示已启用的Google Maps Android API的图像
推荐答案
尝试放置-
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="***"/>
代替-
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="***"/>
并遵循- https://developers.google.com/maps/documentation /android-api/map 说明.
这篇关于Google Maps Android授权失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!