将 EMF 生成的 java 类集成到 Android 项目中

发布于 2024-11-14 12:42:14 字数 2863 浏览 5 评论 0原文

我想知道是否可以将从 EMF(ecore)模型生成的一组类包含到 Android 项目中。

我正在尝试这样做,它编译得很好,但在运行时我收到如下错误:


06-07 11:37:04.261: INFO/dalvikvm(649): Failed resolving Lorg/mmi/events/Event; interface 318 'Lorg/eclipse/emf/ecore/EObject;'
06-07 11:37:04.261: WARN/dalvikvm(649): Link of class 'Lorg/mmi/events/Event;' failed
06-07 11:37:04.261: WARN/dalvikvm(649): VFY: unable to find class referenced in signature (Lorg/mmi/events/Event;)

和这样的:


06-07 12:11:54.953: WARN/dalvikvm(721): threadid=1: thread exiting with uncaught exception (group=0x40014760)
06-07 12:11:55.157: ERROR/AndroidRuntime(721): FATAL EXCEPTION: main
06-07 12:11:55.157: ERROR/AndroidRuntime(721): java.lang.NoClassDefFoundError: org.mmi.model.instantiator.MmiModelInstantiator
06-07 12:11:55.157: ERROR/AndroidRuntime(721):     at org.mmi.facades.MmiFacade.<init>(MmiFacade.java:30)
06-07 12:11:55.157: ERROR/AndroidRuntime(721):     at com.mmi_android.instrumentation.InstrumentationContext.<init>(InstrumentationContext.java:15)
06-07 12:11:55.157: ERROR/AndroidRuntime(721):     at com.mmi_android.instrumentation.InstrumentationContext.get(InstrumentationContext.java:21)
06-07 12:11:55.157: ERROR/AndroidRuntime(721):     at com.example.helloandroid.HelloAndroid.onCreate(HelloAndroid.java:46)
06-07 12:11:55.157: ERROR/AndroidRuntime(721):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
06-07 12:11:55.157: ERROR/AndroidRuntime(721):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1700)
06-07 12:11:55.157: ERROR/AndroidRuntime(721):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1752)
06-07 12:11:55.157: ERROR/AndroidRuntime(721):     at android.app.ActivityThread.access$1500(ActivityThread.java:123)
06-07 12:11:55.157: ERROR/AndroidRuntime(721):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:993)
06-07 12:11:55.157: ERROR/AndroidRuntime(721):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-07 12:11:55.157: ERROR/AndroidRuntime(721):     at android.os.Looper.loop(Looper.java:126)
06-07 12:11:55.157: ERROR/AndroidRuntime(721):     at android.app.ActivityThread.main(ActivityThread.java:3997)
06-07 12:11:55.157: ERROR/AndroidRuntime(721):     at java.lang.reflect.Method.invokeNative(Native Method)
06-07 12:11:55.157: ERROR/AndroidRuntime(721):     at java.lang.reflect.Method.invoke(Method.java:491)
06-07 12:11:55.157: ERROR/AndroidRuntime(721):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
06-07 12:11:55.157: ERROR/AndroidRuntime(721):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
06-07 12:11:55.157: ERROR/AndroidRuntime(721):     at dalvik.system.NativeStart.main(Native Method)

感谢您的帮助!

I would like to know if I can include a set of classes generated from an EMF (ecore) model into an Android project.

I am trying to do this, it compiles fine, but in run-time I get errors like the following ones:


06-07 11:37:04.261: INFO/dalvikvm(649): Failed resolving Lorg/mmi/events/Event; interface 318 'Lorg/eclipse/emf/ecore/EObject;'
06-07 11:37:04.261: WARN/dalvikvm(649): Link of class 'Lorg/mmi/events/Event;' failed
06-07 11:37:04.261: WARN/dalvikvm(649): VFY: unable to find class referenced in signature (Lorg/mmi/events/Event;)

and like this:


06-07 12:11:54.953: WARN/dalvikvm(721): threadid=1: thread exiting with uncaught exception (group=0x40014760)
06-07 12:11:55.157: ERROR/AndroidRuntime(721): FATAL EXCEPTION: main
06-07 12:11:55.157: ERROR/AndroidRuntime(721): java.lang.NoClassDefFoundError: org.mmi.model.instantiator.MmiModelInstantiator
06-07 12:11:55.157: ERROR/AndroidRuntime(721):     at org.mmi.facades.MmiFacade.<init>(MmiFacade.java:30)
06-07 12:11:55.157: ERROR/AndroidRuntime(721):     at com.mmi_android.instrumentation.InstrumentationContext.<init>(InstrumentationContext.java:15)
06-07 12:11:55.157: ERROR/AndroidRuntime(721):     at com.mmi_android.instrumentation.InstrumentationContext.get(InstrumentationContext.java:21)
06-07 12:11:55.157: ERROR/AndroidRuntime(721):     at com.example.helloandroid.HelloAndroid.onCreate(HelloAndroid.java:46)
06-07 12:11:55.157: ERROR/AndroidRuntime(721):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)
06-07 12:11:55.157: ERROR/AndroidRuntime(721):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1700)
06-07 12:11:55.157: ERROR/AndroidRuntime(721):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1752)
06-07 12:11:55.157: ERROR/AndroidRuntime(721):     at android.app.ActivityThread.access$1500(ActivityThread.java:123)
06-07 12:11:55.157: ERROR/AndroidRuntime(721):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:993)
06-07 12:11:55.157: ERROR/AndroidRuntime(721):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-07 12:11:55.157: ERROR/AndroidRuntime(721):     at android.os.Looper.loop(Looper.java:126)
06-07 12:11:55.157: ERROR/AndroidRuntime(721):     at android.app.ActivityThread.main(ActivityThread.java:3997)
06-07 12:11:55.157: ERROR/AndroidRuntime(721):     at java.lang.reflect.Method.invokeNative(Native Method)
06-07 12:11:55.157: ERROR/AndroidRuntime(721):     at java.lang.reflect.Method.invoke(Method.java:491)
06-07 12:11:55.157: ERROR/AndroidRuntime(721):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
06-07 12:11:55.157: ERROR/AndroidRuntime(721):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
06-07 12:11:55.157: ERROR/AndroidRuntime(721):     at dalvik.system.NativeStart.main(Native Method)

Thanks for your help!!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

放赐 2024-11-21 12:42:14

最后,我使用复合 EMF 核心包的类的修改版本解决了这个问题。您可以在这里找到这些课程:

论坛主题:
http://dev.eclipse.org/mhonarc/lists/emf-dev /msg01001.html
项目主页和存储库:
http://code.google。 com/p/smatrt/source/browse/#svn%2Ftrunk%2Ftmp%2Forg%253Fstate%253Dclose

我还需要包含在javax.xml.* 包。我删除了相应的注释,添加了 javax.xml jar 文件,现在一切都可以在 Android 中编译。

希望它能对您将来有所帮助。
干杯!

At the end I solved this problem using a modified version of the classes compounding the EMF core packages. You can find these classes here:

forum thread:
http://dev.eclipse.org/mhonarc/lists/emf-dev/msg01001.html
project homepage and repository:
http://code.google.com/p/smatrt/source/browse/#svn%2Ftrunk%2Ftmp%2Forg%253Fstate%253Dclosed

I needed also the XML classes included in the javax.xml.* package. I removed the corresponding comments, added the javax.xml jar file and now everything compiles in Android.

Hope it can be helpful for you in the future.
Cheers!

夕色琉璃 2024-11-21 12:42:14

最近对相关 Eclipse bug 的评论中,Paul Allen 写道下列:

只是想发布一条说明一切正常。如果我将 org.eclipse.emf.common、org.eclipse.emf.ecore 和 org.eclipse.emf.ecore.xmi 插件中未修改的类与我的模型生成的类一起打包,并将其导入到我的 Android 项目的 libs 文件夹中,一切正常。编译器很高兴。该应用程序在我的 Nexus 7 上运行。生活很美好。

这似乎更可取,因为它不涉及修补核心 EMF 类。不过我自己还没有尝试过。

In a recent comment on the related Eclipse bug, Paul Allen wrote the following:

Just thought I'd post a note that things are working. If I jar up the un-modified classes from the org.eclipse.emf.common, org.eclipse.emf.ecore, and org.eclipse.emf.ecore.xmi plugins along with my model's generated classes, and import that into the libs folder of my Android project, things just work. The compiler's happy. The app runs on my Nexus 7. Life is good.

That seems preferrable, as it doesn't involve patching core EMF classes. I haven't tried it myself yet, though.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文