Google Maps Android API:授权失败 [英] Google Maps Android API: Authorization failure

查看:99
本文介绍了Google Maps Android API:授权失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我阅读了所有讨论的解决方案,但对我不起作用.

I read all discussions solutions but did not work for me.

这些是错误:

  01-01 11:02:47.947 21558-21558/com.cursedchico.IstanbulEventPool E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.cursedchico.IstanbulEventPool.MainActivity.access$super
01-01 11:02:47.947 21558-21558/com.cursedchico.IstanbulEventPool E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.cursedchico.IstanbulEventPool.MainActivity.access$super
01-01 11:02:47.947 21558-21558/com.cursedchico.IstanbulEventPool E/dalvikvm: Could not find class 'android.media.session.MediaController', referenced from method com.cursedchico.IstanbulEventPool.MainActivity.access$super
01-01 11:02:47.947 21558-21558/com.cursedchico.IstanbulEventPool E/dalvikvm: Could not find class 'android.widget.Toolbar', referenced from method com.cursedchico.IstanbulEventPool.MainActivity.access$super
01-01 11:02:47.967 21558-21558/com.cursedchico.IstanbulEventPool E/dalvikvm: Could not find class 'android.app.ActivityManager$TaskDescription', referenced from method com.cursedchico.IstanbulEventPool.MainActivity.access$super
01-01 11:02:47.967 21558-21558/com.cursedchico.IstanbulEventPool E/dalvikvm: Could not find class 'android.app.SharedElementCallback', referenced from method com.cursedchico.IstanbulEventPool.MainActivity.access$super
01-01 11:02:47.967 21558-21558/com.cursedchico.IstanbulEventPool E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.cursedchico.IstanbulEventPool.MainActivity.access$super
01-01 11:02:47.977 21558-21558/com.cursedchico.IstanbulEventPool E/dalvikvm: Could not find class 'android.app.SharedElementCallback', referenced from method com.cursedchico.IstanbulEventPool.MainActivity.access$super
01-01 11:02:48.027 21558-21558/com.cursedchico.IstanbulEventPool E/dalvikvm: Could not find class 'android.app.assist.AssistContent', referenced from method com.cursedchico.IstanbulEventPool.MainActivity.access$super
01-01 11:02:48.037 21558-21558/com.cursedchico.IstanbulEventPool E/dalvikvm: Could not find class 'android.view.SearchEvent', referenced from method com.cursedchico.IstanbulEventPool.MainActivity.access$super
01-01 11:02:48.037 21558-21558/com.cursedchico.IstanbulEventPool E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.cursedchico.IstanbulEventPool.MainActivity.access$super
01-01 11:06:57.301 21558-21558/com.cursedchico.IstanbulEventPool E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.cursedchico.IstanbulEventPool.ListEvents.access$super
01-01 11:06:57.301 21558-21558/com.cursedchico.IstanbulEventPool E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.cursedchico.IstanbulEventPool.ListEvents.access$super
01-01 11:06:57.301 21558-21558/com.cursedchico.IstanbulEventPool E/dalvikvm: Could not find class 'android.media.session.MediaController', referenced from method com.cursedchico.IstanbulEventPool.ListEvents.access$super
01-01 11:06:57.301 21558-21558/com.cursedchico.IstanbulEventPool E/dalvikvm: Could not find class 'android.widget.Toolbar', referenced from method com.cursedchico.IstanbulEventPool.ListEvents.access$super
01-01 11:06:57.301 21558-21558/com.cursedchico.IstanbulEventPool E/dalvikvm: Could not find class 'android.app.ActivityManager$TaskDescription', referenced from method com.cursedchico.IstanbulEventPool.ListEvents.access$super
01-01 11:06:57.311 21558-21558/com.cursedchico.IstanbulEventPool E/dalvikvm: Could not find class 'android.app.SharedElementCallback', referenced from method com.cursedchico.IstanbulEventPool.ListEvents.access$super
01-01 11:06:57.311 21558-21558/com.cursedchico.IstanbulEventPool E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.cursedchico.IstanbulEventPool.ListEvents.access$super
01-01 11:06:57.311 21558-21558/com.cursedchico.IstanbulEventPool E/dalvikvm: Could not find class 'android.app.SharedElementCallback', referenced from method com.cursedchico.IstanbulEventPool.ListEvents.access$super
01-01 11:06:57.321 21558-21558/com.cursedchico.IstanbulEventPool E/dalvikvm: Could not find class 'android.app.assist.AssistContent', referenced from method com.cursedchico.IstanbulEventPool.ListEvents.access$super
01-01 11:06:57.321 21558-21558/com.cursedchico.IstanbulEventPool E/dalvikvm: Could not find class 'android.view.SearchEvent', referenced from method com.cursedchico.IstanbulEventPool.ListEvents.access$super
01-01 11:06:57.321 21558-21558/com.cursedchico.IstanbulEventPool E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.cursedchico.IstanbulEventPool.ListEvents.access$super
01-01 11:06:59.102 21558-21558/com.cursedchico.IstanbulEventPool E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.cursedchico.IstanbulEventPool.ShowEventMap.access$super
01-01 11:06:59.102 21558-21558/com.cursedchico.IstanbulEventPool E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.cursedchico.IstanbulEventPool.ShowEventMap.access$super
01-01 11:06:59.102 21558-21558/com.cursedchico.IstanbulEventPool E/dalvikvm: Could not find class 'android.media.session.MediaController', referenced from method com.cursedchico.IstanbulEventPool.ShowEventMap.access$super
01-01 11:06:59.102 21558-21558/com.cursedchico.IstanbulEventPool E/dalvikvm: Could not find class 'android.widget.Toolbar', referenced from method com.cursedchico.IstanbulEventPool.ShowEventMap.access$super
01-01 11:06:59.102 21558-21558/com.cursedchico.IstanbulEventPool E/dalvikvm: Could not find class 'android.app.ActivityManager$TaskDescription', referenced from method com.cursedchico.IstanbulEventPool.ShowEventMap.access$super
01-01 11:06:59.102 21558-21558/com.cursedchico.IstanbulEventPool E/dalvikvm: Could not find class 'android.app.SharedElementCallback', referenced from method com.cursedchico.IstanbulEventPool.ShowEventMap.access$super
01-01 11:06:59.112 21558-21558/com.cursedchico.IstanbulEventPool E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.cursedchico.IstanbulEventPool.ShowEventMap.access$super
01-01 11:06:59.112 21558-21558/com.cursedchico.IstanbulEventPool E/dalvikvm: Could not find class 'android.app.SharedElementCallback', referenced from method com.cursedchico.IstanbulEventPool.ShowEventMap.access$super
01-01 11:06:59.112 21558-21558/com.cursedchico.IstanbulEventPool E/dalvikvm: Could not find class 'android.app.assist.AssistContent', referenced from method com.cursedchico.IstanbulEventPool.ShowEventMap.access$super
01-01 11:06:59.122 21558-21558/com.cursedchico.IstanbulEventPool E/dalvikvm: Could not find class 'android.view.SearchEvent', referenced from method com.cursedchico.IstanbulEventPool.ShowEventMap.access$super
01-01 11:06:59.122 21558-21558/com.cursedchico.IstanbulEventPool E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method com.cursedchico.IstanbulEventPool.ShowEventMap.access$super
01-01 11:07:00.744 21558-25105/com.cursedchico.IstanbulEventPool E/b: Authentication failed on the server.
01-01 11:07:00.744 21558-25105/com.cursedchico.IstanbulEventPool 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.
01-01 11:07:00.844 21558-25105/com.cursedchico.IstanbulEventPool 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: AIzaSyBK5siQ2-6xawVO-qxQ6Rpxng2t7NYgr1Y
                                                                                                Android Application (<cert_fingerprint>;<package_name>): F5:47:C4:E7:6E:54:BC:99:67:XX:67:6A:CF:XX:7F:DD:A7:D6:E5:77;com.cursedchico.IstanbulEventPool

当我单击android studio的左侧时,我从签名报告中获取了该指纹.它给出了密钥.

I took that fingerprint from signing report , when clicking in the left of android studio. It gave that key.

在Google控制台凭据中,我的密钥:

In google console credentials, my key:

Android key 3   Dec 31, 2015    Android AIzaSyBK5siQ2-6xawVO-qxQ6Rpxng2t7NYgr1Y

我的地图类:

    package com.cursedchico.IstanbulEventPool;

import android.support.v4.app.FragmentActivity;
import android.annotation.TargetApi;
import android.content.Context;
import android.location.Address;
import android.location.Geocoder;
import android.os.Build;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
/*
import com.google.android.gms.maps.model.CircleOptions;
import com.google.maps.android.SphericalUtil;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;*/

import java.io.IOException;
import java.util.List;
import java.util.Locale;

import android.content.Intent;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.cursedchico.IstanbulEventPool.R;

/**
 * Created by Chico on 12/29/2015.
 */

public class ShowEventMap extends AppCompatActivity  {

    private String location;
    private String description;
    private View showView;
    private TextView desc;
    private String TAG = "Chic";
    private Event event;
    private GoogleMap googleMap;
    private LatLng coors;
    private Geocoder geocoder;
    private Context mContext;
    List<Address> From_geocode = null;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.v(TAG, "MapEvents activity oncreate");

        mContext =  getApplicationContext();

        Intent myIntent = getIntent(); // gets the previously created intent
        location =  myIntent.getStringExtra("Location");
        description = myIntent.getStringExtra("Description");
        Log.v(TAG,"loc: "+location+"des: "+description);

        showView = getLayoutInflater().inflate(R.layout.show_description, null);
        desc = (TextView) showView.findViewById(R.id.desc);
       // googleMap = (GoogleMap) showView.findViewById(R.id.map);

        desc.setText(description);
        Log.v(TAG, "desc view geçiş");
        handleLocation(getCoors(location,description));
        setContentView(showView);

    }

    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    private void setUpMap() {
        Log.v(TAG, "setupmapifneeded");
        //if (!isGooglePlayServicesAvailable())
        try {
            if (googleMap == null) {
                Log.v(TAG, "Map created");
                googleMap = ((MapFragment) getFragmentManager().
                        findFragmentById(R.id.map)).getMap();
                googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
            }
            else{
                Log.v(TAG, "hata setupmapifneeded gooogle map null degil");
                //googleMap.addMarker(new MarkerOptions().position(new LatLng(0, 0)).title("Marker"));
            }

        }
        catch (Exception e) {
            e.printStackTrace();
            Log.v(TAG, "catched error setupmap");

        }
    }//setupmap sonu

    private LatLng getCoors(String loc, String desc){
        Log.v(TAG, "getCoors ");
        if (Geocoder.isPresent()) {
            Log.v(TAG, "getCoors geocoder present");
            geocoder = new Geocoder(mContext, Locale.getDefault());
            Log.v(TAG, "location: "+loc);

            try {
                From_geocode = geocoder.getFromLocationName(loc, 1);
            } catch (IOException e) {
                e.printStackTrace();
                Log.v(TAG, "catched error - from geocode");//need to do something
            }

            if (!From_geocode.isEmpty()) {
                Log.v(TAG, " getcoors fromgeocod enot not empty  ");
                coors = new LatLng(From_geocode.get(0).getLatitude(), From_geocode.get(0).getLongitude());


                Log.v(TAG, "LATITUTE=====" + coors.latitude + "   LONGITUTE=====" + coors.longitude);
                return coors;
            }//second if end
            else{
                Log.v(TAG, " hata getcoors fromgeocode empty  ");
            }
        }//first if end
        else{
            Log.v(TAG, " hata getcoors geocoder not preset  ");
        }
        return null;
    }//getcoors end

private void handleLocation(LatLng coor) {
    Log.v(TAG, " handleLocation  ");
    if (coor != null) {
        Log.v(TAG, " handleLocation coor not null ");
        setUpMap();
        MarkerOptions options = new MarkerOptions().position(coor)
                .title("Etkinlik mekani");
        googleMap.addMarker(options);
        float zoomLevel = (float) 12.0; //This goes up to 21
        googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(coor, zoomLevel));

    }
    else{
        Log.v(TAG, " handleLocation coor nnull ");
        setUpMap();//bu olmalı mı degisr belki
    }
    Log.v(TAG, " handleLocation end ");
}




}//class end

我试图更改清单,添加了一些权限和库,我从帖子中看到了,但仍然出现相同的错误:

I tried to change manifest, added some permissions and library, i saw from posts but same error goes on:

 <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.cursedchico.IstanbulEventPool">

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-permission android:name="com.cursedchico.istanbuleventpool.permission.MAPS_RECEIVE" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        <uses-library android:name="com.google.android.maps" />


        <activity android:name="com.cursedchico.IstanbulEventPool.MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity android:name="com.cursedchico.IstanbulEventPool.ListEvents" />
        <activity android:name="com.cursedchico.IstanbulEventPool.ShowEventMap" />
        <activity android:name="com.cursedchico.IstanbulEventPool.AndroidDatabaseManager"
            android:theme="@style/Theme.AppCompat.Light"/>

        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="AIzaSyBK5siQ2-6xawVO-qxQ6Rpxng2t7NYgr1Y" />

    </application>



</manifest>

我只需要显示根据字符串进行地理编码的位置.

I only need to show the location geocoded from string.

我使用真实设备.

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="439dp"
        android:id="@+id/scroll_desc">

        <TextView
              android:id="@+id/desc"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"/>

    </ScrollView>

    <fragment
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.MapFragment"
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:layout_below="@+id/scroll_desc" />

</RelativeLayout>

来自android项目信息:

from android project info:

   Project ID   
istanbuleventpool
Project name    
IstanbulEventPool
Project number  
xxxxx

推荐答案

在Google Developer Console上打开您的项目,并检查您的包名称是否为"com.cursedchico.IstanbulEventPool".如果不同,则将其更改为"com.cursedchico.IstanbulEventPool",然后保存.现在运行您的应用程序,它将正常工作.

Open your project at google developer console and check if you are "com.cursedchico.IstanbulEventPool" as your package name. If it is different then change it to "com.cursedchico.IstanbulEventPool" then save. Now run your app it will work.In my case it worked.

这是它的外观.您需要在包名称中添加"com.cursedchico.IstanbulEventPool"并添加指纹.您将从android studio生成的资源xml中获取此信息.名称为"google_maps_api"

This is how it looks like. You need to add your "com.cursedchico.IstanbulEventPool" in package name and add the finger print. You will get this from android studio generated resource xml. name as "google_maps_api"

这篇关于Google Maps Android API:授权失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆