1

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


}
4

1 回答 1

1

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

作为

机器人:名称

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 清单:为什么有时是“.<classname>” 而不仅仅是“<classname>”?

AndroidManifest.xml 中的活动名称是否需要以点开头?

于 2012-06-13T13:31:13.893 回答