类(一个活动)被声明,但是ClassNotFoundException仍然发生



我已经试图解决这个问题很长一段时间,但仍然被卡住。我已经在AndroidManifest.xml文件中声明了我的活动,但ActivityNotFoundException仍然发生,请帮助!

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sel.appsinfo" >
<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/MyAppTheme" >
    <activity
        android:name="com.sel.appsinfo.AppsInfoMainActivity"
        android:uiOptions="splitActionBarWhenNarrow" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity></application>

Logcat:

08-05 23:37:17.566: W/dalvikvm(26899): Unable to resolve superclass of Lcom/sel/appsinfo/BaseActivity; (85)
08-05 23:37:17.567: W/dalvikvm(26899): Link of class 'Lcom/sel/appsinfo/BaseActivity;' failed
08-05 23:37:17.568: W/dalvikvm(26899): Unable to resolve superclass of Lcom/sel/appsinfo/AppsInfoMainActivity; (166)
08-05 23:37:17.568: W/dalvikvm(26899): Link of class 'Lcom/sel/appsinfo/AppsInfoMainActivity;' failed
08-05 23:37:17.571: D/AndroidRuntime(26899): Shutting down VM
08-05 23:37:17.571: W/dalvikvm(26899): threadid=1: thread exiting with uncaught exception (group=0x40c97258)
08-05 23:37:17.574: E/AndroidRuntime(26899): FATAL EXCEPTION: main
08-05 23:37:17.574: E/AndroidRuntime(26899): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.sel.appsinfo/com.sel.appsinfo.AppsInfoMainActivity}: java.lang.ClassNotFoundException: com.sel.appsinfo.AppsInfoMainActivity
08-05 23:37:17.574: E/AndroidRuntime(26899):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
08-05 23:37:17.574: E/AndroidRuntime(26899):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2023)
08-05 23:37:17.574: E/AndroidRuntime(26899):    at android.app.ActivityThread.access$600(ActivityThread.java:127)
08-05 23:37:17.574: E/AndroidRuntime(26899):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1174)
08-05 23:37:17.574: E/AndroidRuntime(26899):    at android.os.Handler.dispatchMessage(Handler.java:99)
08-05 23:37:17.574: E/AndroidRuntime(26899):    at android.os.Looper.loop(Looper.java:137)
08-05 23:37:17.574: E/AndroidRuntime(26899):    at android.app.ActivityThread.main(ActivityThread.java:4503)
08-05 23:37:17.574: E/AndroidRuntime(26899):    at java.lang.reflect.Method.invokeNative(Native Method)
08-05 23:37:17.574: E/AndroidRuntime(26899):    at java.lang.reflect.Method.invoke(Method.java:511)
08-05 23:37:17.574: E/AndroidRuntime(26899):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)
08-05 23:37:17.574: E/AndroidRuntime(26899):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576)
08-05 23:37:17.574: E/AndroidRuntime(26899):    at dalvik.system.NativeStart.main(Native Method)
08-05 23:37:17.574: E/AndroidRuntime(26899): Caused by: java.lang.ClassNotFoundException: com.sel.appsinfo.AppsInfoMainActivity
08-05 23:37:17.574: E/AndroidRuntime(26899):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
08-05 23:37:17.574: E/AndroidRuntime(26899):    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
08-05 23:37:17.574: E/AndroidRuntime(26899):    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
08-05 23:37:17.574: E/AndroidRuntime(26899):    at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
08-05 23:37:17.574: E/AndroidRuntime(26899):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1911)
08-05 23:37:17.574: E/AndroidRuntime(26899):    ... 11 more

看起来像AppsInfoMainActivity扩展了BaseActivity,但BaseActivity扩展了其他可能无效的东西。确保它正在扩展Activity或AppCompat Activity类,并且导入是正确的

确保XML中的Intent Filter标签包含MAIN也包含

<category android:name="android.intent.category.DEFAULT" />

我认为你的类路径有问题。

如果它正在扩展Activity或AppCompat Activity类,并且导入是正确的,那么依赖列表中可能有2个版本的android-support-v4.jar,但并非所有的版本都是相同的(此时检查仅基于SHA-1)。一切都必须一样。

嗯也许清洁项目会有帮助。

我解决了这个问题,这是因为我包含了太多不必要的库:|

相关内容

  • 没有找到相关文章

最新更新