编程语言
首页 > 编程语言> > android-ClassNotFoundException:找不到我创建的每个应用程序的类“ com.example.app.MainActivity”.

android-ClassNotFoundException:找不到我创建的每个应用程序的类“ com.example.app.MainActivity”.

作者:互联网

您好,每次我在eclipse中创建Android应用程序时,我都会不断收到ClassNotFoundException.在使用月食几个月后直到今天早上,这从未发生过.值得一提的是,今天早上我通过SDK管理器安装了Google Play服务:

11-03 12:39:29.080: E/AndroidRuntime(27547): FATAL EXCEPTION: main
11-03 12:39:29.080: E/AndroidRuntime(27547): Process: com.example.app, PID: 27547
11-03 12:39:29.080: E/AndroidRuntime(27547): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.app/com.example.app.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.app.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.app-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.app-1, /vendor/lib, /system/lib]]
11-03 12:39:29.080: E/AndroidRuntime(27547):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2231)
11-03 12:39:29.080: E/AndroidRuntime(27547):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2363)
11-03 12:39:29.080: E/AndroidRuntime(27547):    at android.app.ActivityThread.access$900(ActivityThread.java:161)
11-03 12:39:29.080: E/AndroidRuntime(27547):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1265)
11-03 12:39:29.080: E/AndroidRuntime(27547):    at android.os.Handler.dispatchMessage(Handler.java:102)
11-03 12:39:29.080: E/AndroidRuntime(27547):    at android.os.Looper.loop(Looper.java:157)
11-03 12:39:29.080: E/AndroidRuntime(27547):    at android.app.ActivityThread.main(ActivityThread.java:5356)
11-03 12:39:29.080: E/AndroidRuntime(27547):    at java.lang.reflect.Method.invokeNative(Native Method)
11-03 12:39:29.080: E/AndroidRuntime(27547):    at java.lang.reflect.Method.invoke(Method.java:515)
11-03 12:39:29.080: E/AndroidRuntime(27547):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
11-03 12:39:29.080: E/AndroidRuntime(27547):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
11-03 12:39:29.080: E/AndroidRuntime(27547):    at dalvik.system.NativeStart.main(Native Method)
11-03 12:39:29.080: E/AndroidRuntime(27547): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.app.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.app-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.app-1, /vendor/lib, /system/lib]]
11-03 12:39:29.080: E/AndroidRuntime(27547):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
11-03 12:39:29.080: E/AndroidRuntime(27547):    at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
11-03 12:39:29.080: E/AndroidRuntime(27547):    at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
11-03 12:39:29.080: E/AndroidRuntime(27547):    at android.app.Instrumentation.newActivity(Instrumentation.java:1079)
11-03 12:39:29.080: E/AndroidRuntime(27547):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2222)

Manifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.app"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="19" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

对此的任何帮助将不胜感激,因为我对此一无所知.

 日食:

解决方法:

打开您的AndroidManifest.xml并检查您是否拥有com.example.app.MainActivity:

    <activity
        android:name="com.example.app.MainActivity"
        android:label="@string/app_name" >
    </activity>

标签:eclipse,android-activity,android-manifest,classnotfoundexception,android
来源: https://codeday.me/bug/20191121/2049131.html