我尝试在我的计算机上编译此示例,并且所有应用都有这样的错误:
04-17 18:01:18.493: E/AndroidRuntime(271): FATAL EXCEPTION: main
04-17 18:01:18.493: E/AndroidRuntime(271): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{sfs2x.example.android.tris/sfs2x.example.android.tris.Tris}: java.lang.ClassNotFoundException: sfs2x.example.android.tris.Tris in loader dalvik.system.PathClassLoader[/data/app/sfs2x.example.android.tris-2.apk]
04-17 18:01:18.493: E/AndroidRuntime(271): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
04-17 18:01:18.493: E/AndroidRuntime(271): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-17 18:01:18.493: E/AndroidRuntime(271): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-17 18:01:18.493: E/AndroidRuntime(271): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-17 18:01:18.493: E/AndroidRuntime(271): at android.os.Handler.dispatchMessage(Handler.java:99)
04-17 18:01:18.493: E/AndroidRuntime(271): at android.os.Looper.loop(Looper.java:123)
04-17 18:01:18.493: E/AndroidRuntime(271): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-17 18:01:18.493: E/AndroidRuntime(271): at java.lang.reflect.Method.invokeNative(Native Method)
04-17 18:01:18.493: E/AndroidRuntime(271): at java.lang.reflect.Method.invoke(Method.java:521)
04-17 18:01:18.493: E/AndroidRuntime(271): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-17 18:01:18.493: E/AndroidRuntime(271): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-17 18:01:18.493: E/AndroidRuntime(271): at dalvik.system.NativeStart.main(Native Method)
04-17 18:01:18.493: E/AndroidRuntime(271): Caused by: java.lang.ClassNotFoundException: sfs2x.example.android.tris.Tris in loader dalvik.system.PathClassLoader[/data/app/sfs2x.example.android.tris-2.apk]
04-17 18:01:18.493: E/AndroidRuntime(271): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
04-17 18:01:18.493: E/AndroidRuntime(271): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
04-17 18:01:18.493: E/AndroidRuntime(271): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
04-17 18:01:18.493: E/AndroidRuntime(271): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
04-17 18:01:18.493: E/AndroidRuntime(271): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
04-17 18:01:18.493: E/AndroidRuntime(271): ... 11 more
从HERE
下载exaples我有:
答案 0 :(得分:2)
我发现我的问题的解决方案是这个链接:
http://android.foxykeep.com/dev/how-to-fix-the-classdefnotfounderror-with-adt-17
特别是:
If you have references to jars that are not in the ‘libs’ folder, for example if you use ‘classpath variable’, you can resolve the NoClassDefFoundError issue with the new ADT 17 by exporting the references.
To export the references: simply go to “Properties > Java Build Path > Order and Export”, and check all the references you want exported.