Google Maps Android API:授权失败

时间:2016-01-01 09:39:03

标签: android google-maps

我阅读了所有讨论解决方案,但对我没有用。

这些都是错误:

  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的左侧点击时,我从签名报告中获取了指纹。它给了那把钥匙。

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

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

我尝试更改清单,添加了一些权限和库,我从帖子中看到但是同样的错误仍在继续:

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

我只需要显示从字符串中进行地理编码的位置。

我使用真实设备。

    <?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项目信息:

   Project ID   
istanbuleventpool
Project name    
IstanbulEventPool
Project number  
xxxxx

1 个答案:

答案 0 :(得分:0)

在google开发者控制台中打开您的项目,并检查您是否<Grid> <DataGrid Name="TestGrid" Height="auto" Width="auto" > <DataGrid.Columns> <DataGridTextColumn> <DataGridTextColumn.ElementStyle> <Style TargetType="{x:Type TextBlock}"> <Style.Triggers> <Trigger Property="Text" Value="0"> <Setter Property="Background" Value="Yellow"/> </Trigger> </Style.Triggers> </Style> </DataGridTextColumn.ElementStyle> </DataGridTextColumn> </DataGrid.Columns> </DataGrid> </Grid> 作为您的包名称。如果不同,则将其更改为"com.cursedchico.IstanbulEventPool"然后保存。现在运行你的应用程序它将工作。在我的情况下它工作。

这是它的样子。您需要在包名称中添加"com.cursedchico.IstanbulEventPool"并添加指纹。你将从android studio生成的资源xml中得到这个。将其命名为&#34; google_maps_api&#34; enter image description here

相关问题