解决:导入第三方包报错java.lang.NoClassDefFoundError:XXX.XXX,XXXXXX

报错信息如下,主要是导入androidpn测试client端,结果报错

04-02 16:28:34.325: E/dalvikvm(485): Could not find class 'org.androidpn.client.PersistentConnectionListener', referenced from method org.androidpn.client.XmppManager.
04-02 16:28:34.335: E/AndroidRuntime(485): FATAL EXCEPTION: main
04-02 16:28:34.335: E/AndroidRuntime(485): java.lang.NoClassDefFoundError: org.androidpn.client.PersistentConnectionListener
04-02 16:28:34.335: E/AndroidRuntime(485): 	at org.androidpn.client.XmppManager.(XmppManager.java:98)
04-02 16:28:34.335: E/AndroidRuntime(485): 	at org.androidpn.client.NotificationService.onCreate(NotificationService.java:115)
04-02 16:28:34.335: E/AndroidRuntime(485): 	at android.app.ActivityThread.handleCreateService(ActivityThread.java:2884)
04-02 16:28:34.335: E/AndroidRuntime(485): 	at android.app.ActivityThread.access$1600(ActivityThread.java:162)
04-02 16:28:34.335: E/AndroidRuntime(485): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1459)
04-02 16:28:34.335: E/AndroidRuntime(485): 	at android.os.Handler.dispatchMessage(Handler.java:99)
04-02 16:28:34.335: E/AndroidRuntime(485): 	at android.os.Looper.loop(Looper.java:158)
04-02 16:28:34.335: E/AndroidRuntime(485): 	at android.app.ActivityThread.main(ActivityThread.java:5751)
04-02 16:28:34.335: E/AndroidRuntime(485): 	at java.lang.reflect.Method.invokeNative(Native Method)
04-02 16:28:34.335: E/AndroidRuntime(485): 	at java.lang.reflect.Method.invoke(Method.java:511)
04-02 16:28:34.335: E/AndroidRuntime(485): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1083)
04-02 16:28:34.335: E/AndroidRuntime(485): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:850)
04-02 16:28:34.335: E/AndroidRuntime(485): 	at dalvik.system.NativeStart.main(Native Method)


原因是在项目中导入第三方包有时候项目不识别其为library

解决方法:

1) 删掉lib包

2)在项目中重新创建lib包,但是要用create -> new -> source folder 而不是 创建新的folder

3)将原来的jar包重新拷贝入lib文件夹中

4) 还没完,要项目右键-->properties -> build path--> 将lib文件夹中的jar包导入项目最为library


最后刷新/restart,完成~!







你可能感兴趣的:(android)