运行错误 - java.lang.RuntimeException:无法实例化活动ComponentInfo

时间:2016-01-15 12:42:23

标签: java android eclipse maven

我在maclipse中添加了一个带有maven的库项目,当运行low时错误返回错误:

01-15 07:35:31.324: E/AndroidRuntime(2783): FATAL EXCEPTION: main
01-15 07:35:31.324: E/AndroidRuntime(2783): Process: com.example.testenfce, PID: 2783
01-15 07:35:31.324: E/AndroidRuntime(2783): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.testenfce/com.example.testenfce.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.testenfce.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.testenfce-2/base.apk"],nativeLibraryDirectories=[/data/app/com.example.testenfce-2/lib/x86, /vendor/lib, /system/lib]]
01-15 07:35:31.324: E/AndroidRuntime(2783):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2327)
01-15 07:35:31.324: E/AndroidRuntime(2783):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
01-15 07:35:31.324: E/AndroidRuntime(2783):     at android.app.ActivityThread.-wrap11(ActivityThread.java)
01-15 07:35:31.324: E/AndroidRuntime(2783):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
01-15 07:35:31.324: E/AndroidRuntime(2783):     at android.os.Handler.dispatchMessage(Handler.java:102)
01-15 07:35:31.324: E/AndroidRuntime(2783):     at android.os.Looper.loop(Looper.java:148)
01-15 07:35:31.324: E/AndroidRuntime(2783):     at android.app.ActivityThread.main(ActivityThread.java:5417)
01-15 07:35:31.324: E/AndroidRuntime(2783):     at java.lang.reflect.Method.invoke(Native Method)
01-15 07:35:31.324: E/AndroidRuntime(2783):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
01-15 07:35:31.324: E/AndroidRuntime(2783):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
01-15 07:35:31.324: E/AndroidRuntime(2783): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.testenfce.MainActivity" on path: DexPathList[[zip file "/data/app/com.example.testenfce-2/base.apk"],nativeLibraryDirectories=[/data/app/com.example.testenfce-2/lib/x86, /vendor/lib, /system/lib]]
01-15 07:35:31.324: E/AndroidRuntime(2783):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
01-15 07:35:31.324: E/AndroidRuntime(2783):     at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
01-15 07:35:31.324: E/AndroidRuntime(2783):     at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
01-15 07:35:31.324: E/AndroidRuntime(2783):     at android.app.Instrumentation.newActivity(Instrumentation.java:1067)
01-15 07:35:31.324: E/AndroidRuntime(2783):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2317)
01-15 07:35:31.324: E/AndroidRuntime(2783):     ... 9 more
01-15 07:35:31.324: E/AndroidRuntime(2783):     Suppressed: java.lang.ClassNotFoundException: com.example.testenfce.MainActivity
01-15 07:35:31.324: E/AndroidRuntime(2783):         at java.lang.Class.classForName(Native Method)
01-15 07:35:31.324: E/AndroidRuntime(2783):         at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
01-15 07:35:31.324: E/AndroidRuntime(2783):         at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
01-15 07:35:31.324: E/AndroidRuntime(2783):         at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
01-15 07:35:31.324: E/AndroidRuntime(2783):         ... 12 more
01-15 07:35:31.324: E/AndroidRuntime(2783):     Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

我现在创建了项目并且只有MainActivity,在添加库之后,项目运行时出现错误MainActivity

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

    <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="23" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.testenfce.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>
有人可以帮助我吗?

0 个答案:

没有答案