我有谷歌地图的问题。当我开始扩展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);
    }


}

最佳答案

android尝试将android:name="NewNormalNoteActivity" as this android:name=".NewNormalNoteActivity"



android:名称

The name of the class that implements the activity, a subclass of Activity.
The attribute value should be a fully qualified class name (such as, "com.example.project.ExtracurricularActivity").
 However, as a shorthand, if the first character of the name is a period (for example, ".ExtracurricularActivity"),
 it is appended to the package name specified in the <manifest> element.


Android Manifest: Why sometimes ".<classname>" instead of just "<classname>"?

Is the activity name in AndroidManifest.xml required to start with a dot?

10-07 19:45
查看更多