gpt4 book ai didi

android - 谷歌地图 Android 授权失败

转载 作者:行者123 更新时间:2023-11-30 01:31:39 26 4
gpt4 key购买 nike

所以我看了很多关于这个问题的问题,但没有找到解决方案。

以下是我在尝试使用 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>): ***

这是我的 list 文件

<?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>

这是 map 的 Fragment.java

    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

<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>

Here's the image showing the enabled Google Maps Android API

Here's the one showing the generated API Key

最佳答案

尝试把-

    <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说明。

关于android - 谷歌地图 Android 授权失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35679341/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com