微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Android项目引用的Android库中的Java库抛出NoClassDefFound

我有一个Android库项目(由我写,有资料),我在Android项目中使用过-到目前为止,还不错,没有问题.但是在该库项目中,我引用了一个外部.jar文件(用于Bixolon移动打印机的SDK),它的构建很好,我可以在我的代码中引用该SDK的方法.但是在运行时我得到了:

   02-16 09:44:43.620: W/dalvikvm(25402): VFY: unable to resolve virtual method 2433: Lcom/bixolon/android/library/BxlService;.GetStatus ()I
    02-16 09:44:43.625: W/dalvikvm(25402): VFY: unable to resolve virtual method 2433: Lcom/bixolon/android/library/BxlService;.GetStatus ()I
    02-16 09:44:43.625: W/dalvikvm(25402): VFY: unable to resolve virtual method 2436: Lcom/bixolon/android/library/BxlService;.MarkFeed (I)I
    02-16 09:44:43.625: W/dalvikvm(25402): VFY: unable to resolve virtual method 2428: Lcom/bixolon/android/library/BxlService;.Directio ([BI[B[I)I
    02-16 09:44:43.630: W/dalvikvm(25402): VFY: unable to resolve virtual method 2437: Lcom/bixolon/android/library/BxlService;.Printimage (Ljava/lang/String;III)I
    02-16 09:44:43.630: W/dalvikvm(25402): VFY: unable to resolve virtual method 2433: Lcom/bixolon/android/library/BxlService;.GetStatus ()I
    02-16 09:44:43.630: W/dalvikvm(25402): VFY: unable to resolve virtual method 2433: Lcom/bixolon/android/library/BxlService;.GetStatus ()I
    02-16 09:44:43.630: W/dalvikvm(25402): VFY: unable to resolve virtual method 2433: Lcom/bixolon/android/library/BxlService;.GetStatus ()I
    02-16 09:44:43.790: W/dalvikvm(25402): threadid=1: thread exiting with uncaught exception (group=0x4001e578)
    02-16 09:44:43.795: E/AndroidRuntime(25402): FATAL EXCEPTION: main
    02-16 09:44:43.795: E/AndroidRuntime(25402): java.lang.NoClassDefFoundError: com.bixolon.android.library.BxlService
    02-16 09:44:43.795: E/AndroidRuntime(25402):    at de.softcon.mobileapp.framework.core.bluetooth.printer.bixolon.BixolonPrinter.connectToPrinter(BixolonPrinter.java:71)
    02-16 09:44:43.795: E/AndroidRuntime(25402):    at de.softcon.mobileapp.framework.core.bluetooth.printer.PrintManager.findPrinter(PrintManager.java:101)
    02-16 09:44:43.795: E/AndroidRuntime(25402):    at de.softcon.mobileapp.framework.core.bluetooth.printer.PrintManager.getPrinter(PrintManager.java:77)

02-16 09:44:43.795: E/AndroidRuntime(25402):    at de.softcon.mobileapp.framework.core.bluetooth.printer.PrintManager.printTestReceipt(PrintManager.java:53)
02-16 09:44:43.795: E/AndroidRuntime(25402):    at de.softcon.mobileoffences.ui.Printer$1.execute(Printer.java:40)
02-16 09:44:43.795: E/AndroidRuntime(25402):    at de.softcon.mobileapp.framework.ui.Dialog.executeActions(Dialog.java:271)
02-16 09:44:43.795: E/AndroidRuntime(25402):    at de.softcon.mobileapp.framework.ui.widgets.DynamicWidget.executeActions(DynamicWidget.java:152)
02-16 09:44:43.795: E/AndroidRuntime(25402):    at de.softcon.mobileapp.framework.ui.widgets.DynamicWidget.executeActions(DynamicWidget.java:138)
02-16 09:44:43.795: E/AndroidRuntime(25402):    at de.softcon.mobileapp.framework.ui.widgets.Button$1.onClick(Button.java:67)
02-16 09:44:43.795: E/AndroidRuntime(25402):    at android.view.View.performClick(View.java:2538)
02-16 09:44:43.795: E/AndroidRuntime(25402):    at android.view.View$PerformClick.run(View.java:9152)
02-16 09:44:43.795: E/AndroidRuntime(25402):    at android.os.Handler.handleCallback(Handler.java:587)
02-16 09:44:43.795: E/AndroidRuntime(25402):    at android.os.Handler.dispatchMessage(Handler.java:92)
02-16 09:44:43.795: E/AndroidRuntime(25402):    at android.os.Looper.loop(Looper.java:130)
02-16 09:44:43.795: E/AndroidRuntime(25402):    at android.app.ActivityThread.main(ActivityThread.java:3691)
02-16 09:44:43.795: E/AndroidRuntime(25402):    at java.lang.reflect.Method.invokeNative(Native Method)
02-16 09:44:43.795: E/AndroidRuntime(25402):    at java.lang.reflect.Method.invoke(Method.java:507)
02-16 09:44:43.795: E/AndroidRuntime(25402):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:907)
02-16 09:44:43.795: E/AndroidRuntime(25402):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:665)
02-16 09:44:43.795: E/AndroidRuntime(25402):    at dalvik.system.NativeStart.main(Native Method)

这让我想知道,是否正确部署了我在Android库项目中引用的.jar …我有一个来自Bixolon的示例项目,该项目直接包含其.jar文件(与我在我的Android库项目中引用的文件相同),并且它工作正常.我已经确保在我自己的Android项目和Android库项目(由Bixolon提供的示例项目中定义)中相同.因此,对于可能出现的问题,我现在有些茫然.不幸的是,我没有所引用的Bixolon SDK .jar的源文件-只有.jar.

解决方法:

查看官方开发指南here

A library project can include a JAR library
You can develop a library project that itself includes a JAR library, however you need to manually edit the dependent application project’s build path and add a path to the JAR file.

除了库项目之外,您还需要手动将jar添加到您的主项目构建路径中,希望有帮助.

从SDK r17更新:

现在,这由ADT自动处理,请查看ADT 17.0.0版本here的新功能

Added feature to automatically setup JAR dependencies. Any .jar files in the /libs folder are added to the build configuration (similar to how the Ant build system works). Also, .jar files needed by library projects are also automatically added to projects that depend on those library projects. (07002)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐