Class(Activity)已声明,但 ClassNotFoundException 仍然发生

Class (an Activity) is declared but ClassNotFoundException still occurs

我已经尝试解决这个问题很长时间了,但仍然被卡住了。 我已经在 AndroidManifest.xml 文件中声明了我的 Activity 但 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.access0(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 class 并且导入正确

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

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

我认为您的 class 路径有问题。请检查 class 路径,如果有误请更正。

我解决了,那是因为我包含了很多不必要的库:|

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

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