Java Android GoogleMaps API v2认证错误,我在AVD上运行时没有收到错误,但在我的nexus 7上收到认证错误
我正在开发一个Android应用程序,它使用Google maps for Android v2。我遇到的问题是,当我在Eclipse中使用AVD运行它时,在log cat输出中没有收到任何身份验证错误 我现在正在Android平板电脑(nexus 7 2013)上测试我的应用程序,我在执行应用程序时收到以下错误:Java Android GoogleMaps API v2认证错误,我在AVD上运行时没有收到错误,但在我的nexus 7上收到认证错误,java,android,eclipse,google-maps,Java,Android,Eclipse,Google Maps,我正在开发一个Android应用程序,它使用Google maps for Android v2。我遇到的问题是,当我在Eclipse中使用AVD运行它时,在log cat输出中没有收到任何身份验证错误 我现在正在Android平板电脑(nexus 7 2013)上测试我的应用程序,我在执行应用程序时收到以下错误: 12-12 01:09:13.968: E/Google Maps Android API(14759): Authorization failure. Please see ht
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
我尝试重新生成API密钥,logcat中的密钥与GoogleAPI控制台中提供的密钥匹配
我在设备上尝试了几次干净的项目/干净的安装,但仍然没有成功。应用程序的rest运行良好,但map不起作用
这是我的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>
这是地图所在的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>
以及守则:
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;
}
}
包dcs.aber.ac.uk.cs211.group02;
导入java.util.Vector;
导入com.google.android.gms.maps.CameraUpdateFactory;
导入com.google.android.gms.maps.GoogleMap;
导入com.google.android.gms.maps.SupportMapFragment;
导入com.google.android.gms.maps.model.LatLng;
导入com.google.android.maps.GeoPoint;
导入android.content.Context;
导入android.content.Intent;
导入android.os.Bundle;
导入android.support.v4.app.FragmentActivity;
导入android.view.Menu;
导入android.view.view;
导入android.view.view.OnClickListener;
导入android.widget.Button;
导入android.widget.ImageButton;
导入android.widget.Toast;
公共类WalkRecording扩展了碎片活动{
私有静态字符串walkName、walkSDesc、walkLdesc;
私人谷歌地图;
私人语境;
私有按钮新建按钮、上传按钮;
私人图像按钮帮助按钮;
私有静态向量poi=新向量();
私人创造者行为;
私有最终静态int NEW_POI_REQ=0;
私人最终静态整数编辑\步行\详细信息=1;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity\u walk\u recording);
上下文=这个;
Bundle Bundle=getIntent().getBundleExtra(“漫游信息”);
if(bundle!=null){
walkName=bundle.getString(“walkTitle”);
walkSDesc=bundle.getString(“walkSDesc”);
walkLdesc=bundle.getString(“walkLdesc”);
}
map=((SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.mapView)).getMap();
地图。移动摄像机(CameraUpdateFactory.newLatLngZoom(新LatLng(52.4140,4.0810),14.0f));
map.setMapType(GoogleMap.map\u TYPE\u NORMAL);
POIAct=新建CreateNewPOIActivity();
addOnClickListeners();
}
public void addOnClickListeners(){
helpButton=(ImageButton)findViewById(R.id.walkRecordingHelpButton);
setOnClickListener(新的OnClickListener(){
@凌驾
公共void onClick(视图v){
意图=新意图(上下文,HelpScreen.class);
星触觉(意向);
}
});
newPOIButton=(按钮)findViewById(R.id.walkRecordingNewPOIButton);
setOnClickListener(newOnClickListener()){
@凌驾
公共void onClick(视图v){
意向意向=新意向(上下文,CreateNewPOIActivity.class);
startActivityForResult(意向、新要求);
}
});
uploadButton=(按钮)findViewById(R.id.walkRecordingUploadButton);
uploadButton.setOnClickListener(新的OnClickListener(){
@凌驾
公共void onClick(视图v){
意向意向=新意向(上下文,ConfrimUploadActivity.class);
Bundle b=新Bundle();
星触觉(意向);
}
});
}
@凌驾
公共布尔onCreateOptions菜单(菜单){
//为菜单充气;这会将项目添加到操作栏(如果存在)。
getMenuInflater().充气(R.menu.walk_录制,菜单);
返回true;
}
public void uploadTosever(){
}
公共步行{
}
公共双getLongitude(){
返回0;
}
公共双getlatitude(){
返回0;
}
公共静态向量getPois(){
返回泊松;
}
受保护的void onActivityResult(int请求代码、int结果代码、意图数据)
{
如果(请求代码==新的请求){
if(resultCode==RESULT\u OK){
兴趣点p=data.getExtras().getParcelable(“POIObject”);
Toast lol=Toast.makeText(上下文,p.getName(),Toast.LENGTH_LONG);
lol.show();
泊松比(p);
Toast x=Toast.makeText(上下文,“POIS SIZE”+POIS.SIZE(),Toast.LENGTH\u LONG);
x、 show();
}
}
else if(requestCode==编辑详细信息){
if(resultCode==RESULT\u OK){
}
}
}
公共静态字符串getWalkName(){
返回walkName;
}
公共静态void setWalkName(字符串walkName){
WalkRecording.walkName=walkName;
}
公共静态字符串getWalkSDesc(){
返回walkSDesc;
}
公共静态void setWalkSDesc(字符串walkSDesc){
WalkRecording.walkSDesc=walkSDesc;
}
公共静态字符串getWalkLdesc(){
返回walkLdesc;
}
公共静态void setWalkLdesc(字符串walkLdesc){
WalkRecording.walkLdesc=walkLdesc;
}
}
有什么想法吗?已解决。