开发者

integrate EMF generated java classes into an Android project

开发者 https://www.devze.com 2023-03-11 09:47 出处:网络
I would like to know if I can include a set of classes generated from an EMF (ecore) model into an Android project.

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 1开发者_运维问答2: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!!!


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!


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号