尝试从我的Nexus 6上的Android Studio运行项目时出错

时间:2015-02-02 18:41:39

标签: android compilation

我通过ADB连接了Nexus 6并且Google USB驱动程序正常运行(我可以从命令行运行adb命令)但是当我尝试在设备上编译我的简单包时,它会吐出这个错误:

`

02-02 13:38:26.091  12659-12659/com.jeremy.myfirstproject E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.jeremy.myfirstproject, PID: 12659
    java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.jeremy.myfirstproject/com.jeremy.myfirstproject.MyActivity}: java.lang.ClassNotFoundException: Didn't find class "com.jeremy.myfirstproject.MyActivity" on path: DexPathList[[zip file "/data/app/com.jeremy.myfirstproject-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2224)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2375)
            at android.app.ActivityThread.access$900(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1293)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5238)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.jeremy.myfirstproject.MyActivity" on path: DexPathList[[zip file "/data/app/com.jeremy.myfirstproject-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
            at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
            at android.app.Instrumentation.newActivity(Instrumentation.java:1065)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2214)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2375)
            at android.app.ActivityThread.access$900(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1293)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5238)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
    Suppressed: java.lang.NoClassDefFoundError: com.jeremy.myfirstproject.MyActivity
            at dalvik.system.DexFile.defineClassNative(Native Method)
            at dalvik.system.DexFile.defineClass(DexFile.java:226)
            at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219)
            at dalvik.system.DexPathList.findClass(DexPathList.java:321)
            at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
            ... 14 more
    Suppressed: java.lang.ClassNotFoundException: com.jeremy.myfirstproject.MyActivity
            at java.lang.Class.classForName(Native Method)
            at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
            at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
            ... 13 more
     Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

`

对文字墙感到抱歉。我不确定这里有什么问题,也许有人可以在这里解决它?

1 个答案:

答案 0 :(得分:0)

在Android studio中创建一个新项目,并将旧项目中的所有内容复制到新项目中。