我有谷歌地图的问题。当我开始扩展 MapActivity 的新活动时,我收到 NoClassDefFoundError。我已使用 google api 将构建目标设置为 2.2,并且
<uses-library android:name="com.google.android.maps" />
<application>
标签内的定义。我也有 mapsApiKey ,我需要让它工作,但它没有。
日志
06-13 15:05:43.276: E/AndroidRuntime(19350): FATAL EXCEPTION: main
06-13 15:05:43.276: E/AndroidRuntime(19350): java.lang.NoClassDefFoundError: pl.mm.dt.AddPlaceActivity
06-13 15:05:43.276: E/AndroidRuntime(19350): at pl.mm.dt.NewNormalNoteActivity$2.onClick(NewNormalNoteActivity.java:67)
06-13 15:05:43.276: E/AndroidRuntime(19350): at android.view.View.performClick(View.java:2495)
06-13 15:05:43.276: E/AndroidRuntime(19350): at android.view.View$PerformClick.run(View.java:9100)
06-13 15:05:43.276: E/AndroidRuntime(19350): at android.os.Handler.handleCallback(Handler.java:587)
06-13 15:05:43.276: E/AndroidRuntime(19350): at android.os.Handler.dispatchMessage(Handler.java:92)
06-13 15:05:43.276: E/AndroidRuntime(19350): at android.os.Looper.loop(Looper.java:130)
06-13 15:05:43.276: E/AndroidRuntime(19350): at android.app.ActivityThread.main(ActivityThread.java:3837)
06-13 15:05:43.276: E/AndroidRuntime(19350): at java.lang.reflect.Method.invokeNative(Native Method)
06-13 15:05:43.276: E/AndroidRuntime(19350): at java.lang.reflect.Method.invoke(Method.java:507)
06-13 15:05:43.276: E/AndroidRuntime(19350): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
06-13 15:05:43.276: E/AndroidRuntime(19350): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
06-13 15:05:43.276: E/AndroidRuntime(19350): at dalvik.system.NativeStart.main(Native Method)
显现
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="pl.mm.dt"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<uses-feature android:name="android.hardware.camera" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<uses-library android:name="com.google.android.maps" />
<activity
android:name=".SplashScreen"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="NewNormalNoteActivity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" >
</activity>
...
<activity
android:name=".AddPlaceActivity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" >
</activity>
</application>
</manifest>
AddPlaceActivity
package pl.mm.dt;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import android.os.Bundle;
public class AddPlaceActivity extends MapActivity{
@Override
protected boolean isRouteDisplayed() {
return false;
}
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.add_place_activity);
MapView mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
}
}