ScriptEngineManager sem = new ScriptEngineManager();scriptEngine = sem.getEngineByExtension(".lua");script = ((Compilable)scriptEngine).compile("some lua here");
然而,这显然不是在AndroID上支持的(与androID没有完整的JVM有关,我在某处阅读).有没有办法在AndroID上使用Lua脚本?也许有一个LuaJ的选择?也许有一种使用LuaJ直接编译和执行Lua脚本的方法(虽然我看不到如何).
FYI,当我尝试在AndroID上运行这个代码时,我看到这个错误:
05-06 16:12:32.870: E/dalvikvm(17509): Could not find class 'javax.script.ScriptEngineManager',referenced from method unearth.levels.LevelReader.<init>05-06 16:12:32.870: W/dalvikvm(17509): VFY: unable to resolve new-instance 787 (Ljavax/script/ScriptEngineManager;) in Lunearth/levels/LevelReader;05-06 16:12:32.870: D/dalvikvm(17509): VFY: replacing opcode 0x22 at 0x001805-06 16:12:32.875: E/dalvikvm(17509): Could not find class 'javax.script.Compilable',referenced from method unearth.levels.LevelReader.parseScript05-06 16:12:32.875: W/dalvikvm(17509): VFY: unable to resolve check-cast 782 (Ljavax/script/Compilable;) in Lunearth/levels/LevelReader;05-06 16:12:32.875: D/dalvikvm(17509): VFY: replacing opcode 0x1f at 0x004705-06 16:12:32.875: W/dalvikvm(17509): VFY: unable to resolve exception class 788 (Ljavax/script/ScriptException;)05-06 16:12:32.875: W/dalvikvm(17509): VFY: unable to find exception handler at addr 0x5105-06 16:12:32.875: W/dalvikvm(17509): VFY: rejected Lunearth/levels/LevelReader;.parseScript (Lorg/w3c/dom/Element;Lunearth/levels/Level;)V05-06 16:12:32.875: W/dalvikvm(17509): VFY: rejecting opcode 0x0d at 0x005105-06 16:12:32.875: W/dalvikvm(17509): VFY: rejected Lunearth/levels/LevelReader;.parseScript (Lorg/w3c/dom/Element;Lunearth/levels/Level;)V05-06 16:12:32.875: W/dalvikvm(17509): VerifIEr rejected class Lunearth/levels/LevelReader;05-06 16:12:32.890: W/dalvikvm(17509): threadID=11: thread exiting with uncaught exception (group=0x40c331f8)05-06 16:12:32.895: E/AndroIDRuntime(17509): FATAL EXCEPTION: GLThread 106205-06 16:12:32.895: E/AndroIDRuntime(17509): java.lang.VerifyError: unearth/levels/LevelReader05-06 16:12:32.895: E/AndroIDRuntime(17509): at unearth.Game.startGame(Game.java:201)05-06 16:12:32.895: E/AndroIDRuntime(17509): at unearth.Game.update(Game.java:713)05-06 16:12:32.895: E/AndroIDRuntime(17509): at unearth.screens.LoadScreen.update(LoadScreen.java:56)05-06 16:12:32.895: E/AndroIDRuntime(17509): at unearth.UnearthListener.render(UnearthListener.java:71)05-06 16:12:32.895: E/AndroIDRuntime(17509): at com.badlogic.gdx.backends.androID.AndroIDGraphics.onDrawFrame(AndroIDGraphics.java:423)05-06 16:12:32.895: E/AndroIDRuntime(17509): at androID.opengl.GLSurfaceVIEw$GLThread.guardedRun(GLSurfaceVIEw.java:1462)05-06 16:12:32.895: E/AndroIDRuntime(17509): at androID.opengl.GLSurfaceVIEw$GLThread.run(GLSurfaceVIEw.java:1216)05-06 16:12:58.600: D/dalvikvm(17509): GC_CONCURRENT freed 334K,3% free 16196K/16647K,paused 2ms+6ms
更新:
也许这个项目有一些有用的代码? http://code.google.com/p/android-scripting/
解决方法 我发现在AndroID上使用LuaJ的一种方法! 总结以上是内存溢出为你收集整理的在Java应用程序中如何在Android上运行Lua脚本?全部内容,希望文章能够帮你解决在Java应用程序中如何在Android上运行Lua脚本?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)