简体   繁体   English

Android GoogleMaps API v2身份验证错误,在AVD上运行时我没有收到错误,但在我的nexus 7上却收到身份验证错误

[英]Android GoogleMaps API v2 auth error, i do not get the error when running on an AVD but on my nexus 7 i get an auth error

I am developing an Android application which uses Google maps for android v2. 我正在开发一个使用Google Maps for android v2的Android应用程序。 The problem i having is that when i run it using the AVD in Eclipse i recieve no authentication error in the log cat output. 我遇到的问题是,当我在Eclipse中使用AVD运行它时,我在log cat输出中未收到任何身份验证错误。

I am now testing my application on an Android tablet (nexus 7 2013) and i recieve this error when executing the application: 我现在正在Android平板电脑(nexus 7 2013)上测试我的应用程序,并且在执行该应用程序时收到此错误:

12-12 01:09:13.968: E/Google Maps Android API(14759): Authorization failure.  Please see https://developers.google.com/maps/documentation/android/start for how to correctly set up the map.
12-12 01:09:13.968: E/Google Maps Android API(14759): Ensure that the following correspond to what is in the API Console: Package Name: dcs.aber.ac.uk.cs211.group02, API Key: AIzaSyDcnzt6cdjEbCXSCRSTezmUHbaPW679if8, Certificate Fingerprint: 52FDB9ABBBAA062226834E35BF6A39FA2A3E27A7

I have tried to regen the API key, the one in the logcat matches the one provided in the google API console. 我试图重新生成API密钥,logcat中的一个与Google API控制台中提供的一个相匹配。

I have tried a clean project/clean install on the device several times, still no luck. 我已经在设备上尝试过几次干净的项目/干净的安装,仍然没有运气。 The reast of the application works fine, only the map does not. 应用程序的其余部分工作正常,只有地图无效。

Here is my manifest.xml al the permissions seem ok. 这是我的manifest.xml,权限似乎还可以。

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="dcs.aber.ac.uk.cs211.group02"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="22" />

    <permission
        android:name="dcs.aber.ac.uk.cs211.group02.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />

    <!-- Accessing camera hardware -->
    <!-- putting android.hardware.camera prevents non-camera devices using this app -->
    <uses-feature android:name="android.hardware.camera" />
    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />

    <uses-permission android:name="dcs.aber.ac.uk.cs211.group02.permission.MAPS_RECEIVE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <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-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:logo="@drawable/ic_launcher"
        android:theme="@style/AppTheme" >
        <uses-library
            android:name="com.google.android.maps"
            android:required="true" />

        <activity
            android:name="dcs.aber.ac.uk.cs211.group02.StartScreen"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="dcs.aber.ac.uk.cs211.group02.CreateWalkActivity"
            android:label="@string/title_activity_create_walk" >
        </activity>
        <activity
            android:name="dcs.aber.ac.uk.cs211.group02.HelpScreen"
            android:label="@string/title_activity_help_screen" >
        </activity>
        <activity
            android:name="dcs.aber.ac.uk.cs211.group02.WalkRecording"
            android:label="@string/title_activity_walk_recording" >
        </activity>
        <activity
            android:name="dcs.aber.ac.uk.cs211.group02.CreateNewPOIActivity"
            android:label="@string/title_activity_create_new_poi" >
        </activity>

        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="AIzaSyDcnzt6cdjEbCXSCRSTezmUHbaPW679if8" />
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

        <activity
            android:name="dcs.aber.ac.uk.cs211.group02.ConfrimUploadActivity"
            android:label="@string/title_activity_confrim_upload" >
        </activity>
        <activity
            android:name="dcs.aber.ac.uk.cs211.group02.ServerResponse"
            android:label="@string/title_activity_server_response" >
        </activity>
    </application>

</manifest>

This is the xml where the map is located: 这是地图所在的xml:

<RelativeLayout 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"
    android:background="@color/black"
    tools:context=".WalkRecording" >

    <fragment

        android:id="@+id/mapView"
        class="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="match_parent"
        android:layout_height="400dp" />

    <ImageButton
        android:id="@+id/walkRecordingHelpButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="20dp"
        android:layout_marginTop="16dp"
        android:background="@color/transparent"
        android:contentDescription="@string/helpIconAltText"
        android:src="@drawable/help" />

    <Button
        android:id="@+id/walkRecordingNewPOIButton"
        style="@android:style/TextAppearance.Small"
        android:layout_width="85dp"
        android:layout_height="50dp"
        android:layout_alignParentBottom="true"
        android:layout_below="@+id/mapView"
        android:layout_marginBottom="8dp"
        android:layout_marginLeft="15dp"
        android:layout_marginTop="8dp"
        android:text="@string/walkRecordingNewPOIButtonText"
        android:textColor="@color/light_gray" />

     <Button
         android:id="@+id/walkRecordingUploadButton"
         style="@android:style/TextAppearance.Small"
         android:layout_width="85dp"
         android:layout_height="50dp"
         android:layout_alignBaseline="@+id/walkRecordingNewPOIButton"
         android:layout_alignBottom="@+id/walkRecordingNewPOIButton"
         android:layout_alignParentRight="true"
         android:layout_marginBottom="8dp"
         android:layout_marginRight="15dp"
         android:layout_marginTop="8dp"
         android:text="@string/walkRecordingUploadButtonText"
         android:textColor="@color/light_gray" />

</RelativeLayout>

And the code: 和代码:

package dcs.aber.ac.uk.cs211.group02;

import java.util.Vector;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.maps.GeoPoint;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.Toast;

public class WalkRecording extends FragmentActivity {

    private static String walkName, walkSDesc, walkLdesc;


    private GoogleMap map;
    private Context context;
    private Button newPOIButton, uploadButton;
    private ImageButton helpButton;
    private static Vector<PointOfInterest> pois = new Vector<PointOfInterest>();

    private CreateNewPOIActivity POIAct;

    private final static int NEW_POI_REQ = 0;
    private final static int EDIT_WALK_DETAILS = 1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_walk_recording);
        context = this;

        Bundle bundle = getIntent().getBundleExtra("Walk info");

        if(bundle != null){

            walkName = bundle.getString("walkTitle");
            walkSDesc = bundle.getString("walkSdesc");
            walkLdesc = bundle.getString("walkLDesc");

        }


        map=((SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.mapView)).getMap();

        map.moveCamera( CameraUpdateFactory.newLatLngZoom(new LatLng(52.4140,4.0810) , 14.0f));         

        map.setMapType(GoogleMap.MAP_TYPE_NORMAL);




        POIAct = new CreateNewPOIActivity();

        addOnClickListeners();
    }


    public void addOnClickListeners(){

        helpButton = (ImageButton) findViewById(R.id.walkRecordingHelpButton);

        helpButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {

                Intent intent = new Intent(context, HelpScreen.class);
                startActivity(intent);   

            }

        });

        newPOIButton = (Button) findViewById(R.id.walkRecordingNewPOIButton);

        newPOIButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {

                Intent intent = new Intent(context, CreateNewPOIActivity.class);
                startActivityForResult(intent, NEW_POI_REQ);   

            }

        });

        uploadButton = (Button) findViewById(R.id.walkRecordingUploadButton);

        uploadButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v){

                Intent intent = new Intent(context, ConfrimUploadActivity.class);
                Bundle b = new Bundle();


                startActivity(intent);
            }
        });

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.walk_recording, menu);
        return true;
    }


    public void uploadTosever() {




    }

    public void deleteWalk() {


    }

    public double getLongitude() {

        return 0;
    }

    public double getLattitude() {

        return 0;

    }


    public static Vector<PointOfInterest> getPois() {
        return pois;
    }

    protected void onActivityResult(int requestCode, int resultCode, Intent data)
    {
        if(requestCode == NEW_POI_REQ){
            if( resultCode == RESULT_OK ) {
                PointOfInterest p = data.getExtras().getParcelable("POIObject");
                Toast lol = Toast.makeText(context, p.getName(), Toast.LENGTH_LONG);
                lol.show();
                pois.add(p);
                Toast x = Toast.makeText(context, "POIS SIZE " + pois.size() , Toast.LENGTH_LONG);
                x.show();

            }
        }
        else if(requestCode == EDIT_WALK_DETAILS){
            if( resultCode == RESULT_OK ) {



            }

        }
    }

    public static String getWalkName() {
        return walkName;
    }


    public static void setWalkName(String walkName) {
        WalkRecording.walkName = walkName;
    }


    public static String getWalkSDesc() {
        return walkSDesc;
    }


    public static void setWalkSDesc(String walkSDesc) {
        WalkRecording.walkSDesc = walkSDesc;
    }


    public static String getWalkLdesc() {
        return walkLdesc;
    }


    public static void setWalkLdesc(String walkLdesc) {
        WalkRecording.walkLdesc = walkLdesc;
    }

}

Any ideas? 有任何想法吗?

Resolved. 解决。 alls it took was a device reset... 麻烦的是设备重置...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我有错误未加载google map android api v2 - I Have Error a google map android api v2 is not loaded 为什么我得到错误ClassNotFoundException:com.amazonaws.auth.AWSCredentialsProvider? - Why I get error ClassNotFoundException: com.amazonaws.auth.AWSCredentialsProvider? 在Heroku上运行我的应用程序时,为什么会出现启动超时错误(错误R10)? - Why do I get a Boot timeout error (Error R10) when running my app on Heroku? 运行google maps api v2时出错 - error running google maps api v2 使用Android Google Map API(v2)获取当前位置,但不幸的是应用程序已停止错误 - Get Current Location with Android Google Map API(v2) but getting Unfortunately application has stopped error Android - 错误膨胀类片段(试图让谷歌地图api v2工作) - Android - Error inflating class fragment (trying to get google maps api v2 to work) GoogleMap Android API V2捕获错误 - GoogleMap Android API V2 Capture Error 我无法让Google Maps API在我的Android应用程序(V2)上运行 - I cannot get Google Maps API to work on my android Application (V2) 运行 JFrame 代码时出现此错误? - When running JFrame Code I get this error? 在Android应用程序中使用Jersey for restful api时出现此错误: - When using Jersey for restful api in Android app I get this error:
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM