简体   繁体   中英

Run scala code on android devices

I'm trying to port Apache Flink to Android. This framework is partially written in Scala and during the execution of the word count example, an exception is thrown (with many others that I'll not post) as:

...
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lscala/sys/package$;
at org.apache.flink.runtime.minicluster.FlinkMiniCluster.setDefaultCiConfig(FlinkMiniCluster.scala:196)
at org.apache.flink.runtime.minicluster.LocalFlinkMiniCluster.generateConfiguration(LocalFlinkMiniCluster.scala:58)
at org.apache.flink.runtime.minicluster.FlinkMiniCluster.<init>(FlinkMiniCluster.scala:76)
at org.apache.flink.runtime.minicluster.LocalFlinkMiniCluster.<init>(LocalFlinkMiniCluster.scala:47)
at org.apache.flink.client.LocalExecutor.start(LocalExecutor.java:114)
at org.apache.flink.client.LocalExecutor.executePlan(LocalExecutor.java:173)
at org.apache.flink.api.java.LocalEnvironment.execute(LocalEnvironment.java:90)
at org.apache.flink.api.java.ExecutionEnvironment.execute(ExecutionEnvironment.java:855)
at org.apache.flink.api.java.DataSet.collect(DataSet.java:410)
at hk.ust.symlab.mobiflink.MainActivity$collectActivity.doInBackground(MainActivity.java:86)
at hk.ust.symlab.mobiflink.MainActivity$collectActivity.doInBackground(MainActivity.java:81)
at android.os.AsyncTask$2.call(AsyncTask.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
at java.lang.Thread.run(Thread.java:818) 
...

With the exceptions it seems that the Android device cannot run scala code (correct me if I'm wrong).

I've found many post about Android and Scala, but they seem more about write scala in Android applications to make the code simpler and shorter.

I've found this question about the topic but isn't helpful.

So the question is : how to run scala code on Android devices? Or alternatively: can Android run Scala code?

Scala programs require the Scala runtime library. You need to include that jar file in your application.

This is not specific to Android, but applies to desktop Java as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM