ecplise调试 java.lang.NoClassDefFoundError异常解决方法

外部android工程import到ecplise中去,编译正常,运行报错,logcat 如下:

12-19 10:55:25.915: E/AndroidRuntime(2929): FATAL EXCEPTION: main
12-19 10:55:25.915: E/AndroidRuntime(2929): java.lang.NoClassDefFoundError: com.guet.SiriCN.MainActivity$1
12-19 10:55:25.915: E/AndroidRuntime(2929):  at com.XXX.MainActivity.(MainActivity.java:189)
12-19 10:55:25.915: E/AndroidRuntime(2929):  at java.lang.Class.newInstanceImpl(Native Method)
12-19 10:55:25.915: E/AndroidRuntime(2929):  at java.lang.Class.newInstance(Class.java:1429)
12-19 10:55:25.915: E/AndroidRuntime(2929):  at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
12-19 10:55:25.915: E/AndroidRuntime(2929):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
12-19 10:55:25.915: E/AndroidRuntime(2929):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
12-19 10:55:25.915: E/AndroidRuntime(2929):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
12-19 10:55:25.915: E/AndroidRuntime(2929):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
12-19 10:55:25.915: E/AndroidRuntime(2929):  at android.os.Handler.dispatchMessage(Handler.java:99)
12-19 10:55:25.915: E/AndroidRuntime(2929):  at android.os.Looper.loop(Looper.java:123)
12-19 10:55:25.915: E/AndroidRuntime(2929):  at android.app.ActivityThread.main(ActivityThread.java:4627)
12-19 10:55:25.915: E/AndroidRuntime(2929):  at java.lang.reflect.Method.invokeNative(Native Method)
12-19 10:55:25.915: E/AndroidRuntime(2929):  at java.lang.reflect.Method.invoke(Method.java:521)
12-19 10:55:25.915: E/AndroidRuntime(2929):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run

找了很多原因,最后发现时引入外部jar包的时候,如果该jar包不在lib目录中,需要单独再引用一次,解决方法如下:

properties - java build path - order and export页面

你可能感兴趣的:(技术文章)