I've been trying to run Java applications on android devices as standalone jars (not as apk's). Everything went fine in the beginning: I used the dex compiler from the Android SDK, packed the dex file into a jar, pushed it to the device and used a shell script (similar to the example in the link) to run it.
When I included more libraries and hit the 65K dex function limit, I used the --multi-dex flag with the dex compiler. The compilation succeeded, and I was also able to run my code on a Lollipop device. However, running the exact same jar on Kitkat gets the following run-time exception:
java.lang.VerifyError: scala/None$
at akka.actor.ActorSystem$.<init>(ActorSystem.scala:30)
at akka.actor.ActorSystem$.<clinit>(ActorSystem.scala)
at akka.actor.ActorSystem.create(ActorSystem.scala)
at com.example.MyClass.calculate(MyClass.java:185)
at com.example.Main.main(Main.java:16)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:243)
at dalvik.system.NativeStart.main(Native Method)
I faced the exact same problem when I tried running the same code as an apk, and solved it by adding a line to the Android Manifest:
android:name="android.support.multidex.MultiDexApplication"
This obviously isn't possible in the current situation, since I don't have manifest file.
How can I still enable the multidex support for my standalone jar? Should I add libraries to the compilation? Should I run the jar differently?
Thanks.