Android ClassDefNotFoundException-但直到10分钟前,它还可以正常工作
我目前正在开发一个android应用程序,它需要在地图上显示一个位置,并在该位置显示一堆带标签的照片。在过去的一天半时间里,我一直在努力让google API正常工作,现在他们的错误(似乎)已经消失了,在将google play API项目导入Eclipse之后(根据google参考),我现在在OnClick按钮上得到了ClassDefNotFoundException。这并没有发生,而是在10分钟前,在我引用API项目之前 我今天需要解决这个问题,所以任何能提供的帮助都将非常感谢 这里是调试屏幕的屏幕截图(您可以看到,缺少的类就在它旁边提供)Android ClassDefNotFoundException-但直到10分钟前,它还可以正常工作,android,noclassdeffounderror,google-maps-api-2,Android,Noclassdeffounderror,Google Maps Api 2,我目前正在开发一个android应用程序,它需要在地图上显示一个位置,并在该位置显示一堆带标签的照片。在过去的一天半时间里,我一直在努力让google API正常工作,现在他们的错误(似乎)已经消失了,在将google play API项目导入Eclipse之后(根据google参考),我现在在OnClick按钮上得到了ClassDefNotFoundException。这并没有发生,而是在10分钟前,在我引用API项目之前 我今天需要解决这个问题,所以任何能提供的帮助都将非常感谢 这里是调试屏
它只发生在使用这一个按钮时,每一个按钮都工作得很好 GMapActivity.class
package com.pragsys.android.gps;
import com.google.android.gms.maps.SupportMapFragment;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
public class GMapActivity extends FragmentActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_gmap);
SupportMapFragment frag = new SupportMapFragment();
getSupportFragmentManager().beginTransaction().add(android.R.id.content, frag).commit();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.gmap, menu);
return true;
}
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.pragsys.android.gps"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="17" />
<permission
android:name="com.pragsys.android.gps.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.pragsys.android.gps.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="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<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="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<uses-library android:name="com.google.android.maps" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyByBoq02A_DiWygIHdmidfVWVWrHWslbX4"/>
<activity
android:name="com.pragsys.android.gps.MainActivity"
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=".TakePhotoActivity"
android:label="@string/title_activity_take_photo" >
</activity>
<activity
android:name=".PhotoOverviewActivity"
android:label="@string/title_activity_photo_overview" >
</activity>
<activity
android:name=".PhotoGalleryActivity"
android:label="@string/title_activity_photo_gallery" >
</activity>
<activity
android:name=".PhotoUploadedActivity"
android:label="@string/title_activity_photo_uploaded" >
</activity>
<activity
android:name=".AboutActivity"
android:label="@string/title_activity_about" >
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="-snip-" />
<activity
android:name=".GMapActivity"
android:label="@string/title_activity_gmap" >
</activity>
</application>
</manifest>
layout.xml
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"/>
-天籁之音-
好吧,我想我只是通过改变来解决这个问题
android:name="com.google.android.gms.maps.MapFragment" />
到
这将教会我如何盲目复制粘贴参考资料。
编辑:工作到凌晨3点。您是否参考了google play services库?通常,NoClassDefFoundError表示在Eclipse中设置项目的方式有问题,而不是代码有问题。我会仔细检查库的设置方式,然后尝试重新启动eclipse和/或刷新项目(您可以通过在项目浏览器中突出显示并点击f5来完成)。是的,我引用了google play服务。Logcat准确地告诉了您我所说的——一个onClick处理程序的GMapActivity.class缺少一个ClassDef,该处理程序在5分钟前还在工作。我已经回答了下面我自己的问题。我想我已经解决了这个具体的错误。。现在我想知道为什么我在谷歌地图上只看到+-按钮:P@Neglected这通常发生在API密钥不正确时。
android:name="com.google.android.gms.maps.SupportMapFragment" />