Android ClassNotFoundException

时间:2012-05-20 22:26:05

标签: android manifest

我的应用程序有问题,昨天一切正常,但今天我更新了sdk,现在当我试图运行我的应用程序时,我遇到了这样的错误

 05-21 00:14:19.285: W/dalvikvm(7061): Unable to resolve superclass of Lcom/lpp/towndefence/MainMenuActivity; (122)
05-21 00:14:19.285: W/dalvikvm(7061): Link of class 'Lcom/lpp/towndefence/MainMenuActivity;' failed
05-21 00:14:19.285: D/AndroidRuntime(7061): Shutting down VM
05-21 00:14:19.285: W/dalvikvm(7061): threadid=1: thread exiting with uncaught exception (group=0x40018560)
05-21 00:14:19.345: E/AndroidRuntime(7061): FATAL EXCEPTION: main
05-21 00:14:19.345: E/AndroidRuntime(7061): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.lpp.towndefence/com.lpp.towndefence.MainMenuActivity}: java.lang.ClassNotFoundException: com.lpp.towndefence.MainMenuActivity in loader dalvik.system.PathClassLoader[/data/app/com.lpp.towndefence-1.apk]
05-21 00:14:19.345: E/AndroidRuntime(7061):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1679)
05-21 00:14:19.345: E/AndroidRuntime(7061):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1783)
05-21 00:14:19.345: E/AndroidRuntime(7061):     at android.app.ActivityThread.access$1500(ActivityThread.java:123)
05-21 00:14:19.345: E/AndroidRuntime(7061):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:938)
05-21 00:14:19.345: E/AndroidRuntime(7061):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-21 00:14:19.345: E/AndroidRuntime(7061):     at android.os.Looper.loop(Looper.java:130)
05-21 00:14:19.345: E/AndroidRuntime(7061):     at android.app.ActivityThread.main(ActivityThread.java:3837)
05-21 00:14:19.345: E/AndroidRuntime(7061):     at java.lang.reflect.Method.invokeNative(Native Method)
05-21 00:14:19.345: E/AndroidRuntime(7061):     at java.lang.reflect.Method.invoke(Method.java:507)
05-21 00:14:19.345: E/AndroidRuntime(7061):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
05-21 00:14:19.345: E/AndroidRuntime(7061):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
05-21 00:14:19.345: E/AndroidRuntime(7061):     at dalvik.system.NativeStart.main(Native Method)
05-21 00:14:19.345: E/AndroidRuntime(7061): Caused by: java.lang.ClassNotFoundException: com.lpp.towndefence.MainMenuActivity in loader dalvik.system.PathClassLoader[/data/app/com.lpp.towndefence-1.apk]
05-21 00:14:19.345: E/AndroidRuntime(7061):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
05-21 00:14:19.345: E/AndroidRuntime(7061):     at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
05-21 00:14:19.345: E/AndroidRuntime(7061):     at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
05-21 00:14:19.345: E/AndroidRuntime(7061):     at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
05-21 00:14:19.345: E/AndroidRuntime(7061):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1671)
05-21 00:14:19.345: E/AndroidRuntime(7061):     ... 11 more

我的清单

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.lpp.towndefence"
    android:versionCode="1"
    android:versionName="1.0" >
    <uses-sdk android:minSdkVersion="7"/>
    <uses-permission android:name="android.permission.WAKE_LOCK"/>
    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:label="@string/app_name"
            android:name=".MainMenuActivity" >
            <intent-filter >
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity 
            android:name=".TownDefenseActivity">
        </activity>
    </application>

</manifest>

我清理了项目,修复了项目属性,但没有帮助。

1 个答案:

答案 0 :(得分:1)

就像@Barak所说:jar文件进入libs目录。但请确保在“项目属性”中检查库 - &gt; “java build path” - &gt; “订购和出口”也是。