关于android的JIBX。 LogCat show:找不到类'X',从方法'Y + exception java.lang.VerifyError引用

时间:2013-09-10 14:41:10

标签: java android xsd jibx

我在Eclipse上编写了一个使用lib JIBX的应用程序。我强调要遵循本教程:" http://www.ibm.com/developerworks/java/tutorials/j-jibx2/"。它完美地适用于经典的JAVA项目。我可以从classe生成一个xsd,从xsd生成类并执行返回更正结果的程序。

我想在android上做这个tuto。我导入了与经典项目中相同的库(JIBX应该在android上工作)。我可以生成类和对象,但是当我尝试编译这个项目时,虚拟手机上会出现错误,LogCat会显示以下消息:

09-10 12:33:54.957: I/Process(1905): Sending signal. PID: 1905 SIG: 9
09-10 12:34:05.047: I/dalvikvm(1944): Could not find method org.jibx.runtime.BindingDirectory.getFactory, referenced from method com.example.jibxtestandroid.MainActivity.calcul
09-10 12:34:05.079: W/dalvikvm(1944): VFY: unable to resolve static method 25: Lorg/jibx/runtime/BindingDirectory;.getFactory (Ljava/lang/Class;)Lorg/jibx/runtime/IBindingFactory;
09-10 12:34:05.079: D/dalvikvm(1944): VFY: replacing opcode 0x71 at 0x0004
09-10 12:34:05.079: W/dalvikvm(1944): VFY: unable to resolve exception class 34 (Lorg/jibx/runtime/JiBXException;)
09-10 12:34:05.079: W/dalvikvm(1944): VFY: unable to find exception handler at addr 0x8
09-10 12:34:05.087: W/dalvikvm(1944): VFY:  rejected Lcom/example/jibxtestandroid/MainActivity;.calcul ()Ljava/lang/String;
09-10 12:34:05.087: W/dalvikvm(1944): VFY:  rejecting opcode 0x0d at 0x0008
09-10 12:34:05.087: W/dalvikvm(1944): VFY:  rejected Lcom/example/jibxtestandroid/MainActivity;.calcul ()Ljava/lang/String;
09-10 12:34:05.087: W/dalvikvm(1944): Verifier rejected class Lcom/example/jibxtestandroid/MainActivity;
09-10 12:34:05.087: W/dalvikvm(1944): Class init failed in newInstance call (Lcom/example/jibxtestandroid/MainActivity;)
09-10 12:34:05.087: D/AndroidRuntime(1944): Shutting down VM
09-10 12:34:05.087: W/dalvikvm(1944): threadid=1: thread exiting with uncaught exception (group=0x414c4700)
09-10 12:34:05.147: E/AndroidRuntime(1944): FATAL EXCEPTION: main
09-10 12:34:05.147: E/AndroidRuntime(1944): java.lang.VerifyError: com/example/jibxtestandroid/MainActivity
09-10 12:34:05.147: E/AndroidRuntime(1944):     at java.lang.Class.newInstanceImpl(Native Method)
09-10 12:34:05.147: E/AndroidRuntime(1944):     at java.lang.Class.newInstance(Class.java:1130)
09-10 12:34:05.147: E/AndroidRuntime(1944):     at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
09-10 12:34:05.147: E/AndroidRuntime(1944):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
09-10 12:34:05.147: E/AndroidRuntime(1944):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
09-10 12:34:05.147: E/AndroidRuntime(1944):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
09-10 12:34:05.147: E/AndroidRuntime(1944):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
09-10 12:34:05.147: E/AndroidRuntime(1944):     at android.os.Handler.dispatchMessage(Handler.java:99)
09-10 12:34:05.147: E/AndroidRuntime(1944):     at android.os.Looper.loop(Looper.java:137)
09-10 12:34:05.147: E/AndroidRuntime(1944):     at android.app.ActivityThread.main(ActivityThread.java:5103)
09-10 12:34:05.147: E/AndroidRuntime(1944):     at java.lang.reflect.Method.invokeNative(Native Method)
09-10 12:34:05.147: E/AndroidRuntime(1944):     at java.lang.reflect.Method.invoke(Method.java:525)
09-10 12:34:05.147: E/AndroidRuntime(1944):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
09-10 12:34:05.147: E/AndroidRuntime(1944):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-10 12:34:05.147: E/AndroidRuntime(1944):     at dalvik.system.NativeStart.main(Native Method)
09-10 12:39:05.443: I/Process(1944): Sending signal. PID: 1944 SIG: 9

我开始添加到build-path jibx-run.jar并按顺序和导出交叉。我甚至把它放在了顶部。没有任何改变,消息错误仍然是相同的。所以我做了同样的事情,但是在我的项目中使用从JIBX导入的所有lib。然后,eclipse崩溃并在一个框中显示:"无法执行dex:Java堆空间",这表明lib太大(7 Mo) 你有个主意吗? Libs被正确包含在Eclipse中没有错误。 感谢

1 个答案:

答案 0 :(得分:1)

Android programming with JiBX查看我的博客,了解如何在Android上使用JiBX。

祝你好运!

唐科利

JiBX撰稿人