Android:没找到MainActivity?

时间:2014-03-17 21:50:36

标签: android eclipse

大家好!

我为Android应用程序收到以下错误:

E/AndroidRuntime(1039): FATAL EXCEPTION: main
E/AndroidRuntime(1039): Process: com.example.lifeahead, PID: 1039
E/AndroidRuntime(1039): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.lifeahead/com.example.lifeahead.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.lifeahead.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.lifeahead-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.lifeahead-1, /system/lib]]
E/AndroidRuntime(1039):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2121)
E/AndroidRuntime(1039):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
E/AndroidRuntime(1039):     at android.app.ActivityThread.access$800(ActivityThread.java:135)
E/AndroidRuntime(1039):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
E/AndroidRuntime(1039):     at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(1039):     at android.os.Looper.loop(Looper.java:136)
E/AndroidRuntime(1039):     at android.app.ActivityThread.main(ActivityThread.java:5017)
E/AndroidRuntime(1039):     at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(1039):     at java.lang.reflect.Method.invoke(Method.java:515)
E/AndroidRuntime(1039):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
E/AndroidRuntime(1039):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
E/AndroidRuntime(1039):     at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(1039): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.lifeahead.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.lifeahead-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.lifeahead-1, /system/lib]]
E/AndroidRuntime(1039):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
E/AndroidRuntime(1039):     at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
E/AndroidRuntime(1039):     at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
E/AndroidRuntime(1039):     at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
E/AndroidRuntime(1039):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
E/AndroidRuntime(1039):     ... 11 more

XML Manifest:

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

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

        <activity
            android:name="com.example.lifeahead.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>

        <activity
            android:name="com.example.lifeahead.HomeActivity"
            android:label="@string/title_activity_home" >
        </activity>
        <activity
            android:name="com.example.lifeahead.SchedulesActivity"
            android:label="@string/title_activity_schedules" >
        </activity>
        <activity
            android:name="com.example.lifeahead.SearchActivity"
            android:label="@string/title_activity_search" >
        </activity>
    </application>

</manifest>

Thanks for your help!

1 个答案:

答案 0 :(得分:-1)

将活动名称设置为:

<activity
   android:name=".MainActivity"