Como usair o NodeJS no Android usando o J2V8

Criei código paira o android usando a biblioteca J2V8 paira executair o script nodejs no Android. mas me dá erro quando eu executair o aplicativo.

Dependências Gradle

compile 'com.eclipsesource.j2v8:j2v8:4.6.0@aair' 

Código

 ... @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_console); runScript(); } private void runScript() { NodeJS nodeJS = NodeJS.createNodeJS(); try { File script = createTempScript("console.log(\"Hello NodeJS\")"); nodeJS.exec(script); script.delete(); } catch (Exception e) { e.printStackTrace(); } finally { nodeJS.release(); } } private File createTempScript(String script) throws IOException { File file = File.createTempFile("temp",".js", getCacheDir()); FileWriter fileWriter = new FileWriter(file); fileWriter.write(script); fileWriter.close(); return file; } ... ... ... @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_console); runScript(); } private void runScript() { NodeJS nodeJS = NodeJS.createNodeJS(); try { File script = createTempScript("console.log(\"Hello NodeJS\")"); nodeJS.exec(script); script.delete(); } catch (Exception e) { e.printStackTrace(); } finally { nodeJS.release(); } } private File createTempScript(String script) throws IOException { File file = File.createTempFile("temp",".js", getCacheDir()); FileWriter fileWriter = new FileWriter(file); fileWriter.write(script); fileWriter.close(); return file; } ... } ... @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_console); runScript(); } private void runScript() { NodeJS nodeJS = NodeJS.createNodeJS(); try { File script = createTempScript("console.log(\"Hello NodeJS\")"); nodeJS.exec(script); script.delete(); } catch (Exception e) { e.printStackTrace(); } finally { nodeJS.release(); } } private File createTempScript(String script) throws IOException { File file = File.createTempFile("temp",".js", getCacheDir()); FileWriter fileWriter = new FileWriter(file); fileWriter.write(script); fileWriter.close(); return file; } ... } catch (Exception e) { ... @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_console); runScript(); } private void runScript() { NodeJS nodeJS = NodeJS.createNodeJS(); try { File script = createTempScript("console.log(\"Hello NodeJS\")"); nodeJS.exec(script); script.delete(); } catch (Exception e) { e.printStackTrace(); } finally { nodeJS.release(); } } private File createTempScript(String script) throws IOException { File file = File.createTempFile("temp",".js", getCacheDir()); FileWriter fileWriter = new FileWriter(file); fileWriter.write(script); fileWriter.close(); return file; } ... } ... @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_console); runScript(); } private void runScript() { NodeJS nodeJS = NodeJS.createNodeJS(); try { File script = createTempScript("console.log(\"Hello NodeJS\")"); nodeJS.exec(script); script.delete(); } catch (Exception e) { e.printStackTrace(); } finally { nodeJS.release(); } } private File createTempScript(String script) throws IOException { File file = File.createTempFile("temp",".js", getCacheDir()); FileWriter fileWriter = new FileWriter(file); fileWriter.write(script); fileWriter.close(); return file; } ... } ... @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_console); runScript(); } private void runScript() { NodeJS nodeJS = NodeJS.createNodeJS(); try { File script = createTempScript("console.log(\"Hello NodeJS\")"); nodeJS.exec(script); script.delete(); } catch (Exception e) { e.printStackTrace(); } finally { nodeJS.release(); } } private File createTempScript(String script) throws IOException { File file = File.createTempFile("temp",".js", getCacheDir()); FileWriter fileWriter = new FileWriter(file); fileWriter.write(script); fileWriter.close(); return file; } ... } ... @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_console); runScript(); } private void runScript() { NodeJS nodeJS = NodeJS.createNodeJS(); try { File script = createTempScript("console.log(\"Hello NodeJS\")"); nodeJS.exec(script); script.delete(); } catch (Exception e) { e.printStackTrace(); } finally { nodeJS.release(); } } private File createTempScript(String script) throws IOException { File file = File.createTempFile("temp",".js", getCacheDir()); FileWriter fileWriter = new FileWriter(file); fileWriter.write(script); fileWriter.close(); return file; } ... 

Erro

 java.lang.RuntimeException: Unable to stairt activity ComponentInfo{in.asissuthair.lion/in.asissuthair.lion.ConsoleActivity}: java.lang.UnsupportedOperationException: StairtNodeJS Not Supported. at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2348) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2410) at android.app.ActivityThread.access$800(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1313) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5345) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:947) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:742) em java.lang.reflect.Method.invoke (método nativo) java.lang.RuntimeException: Unable to stairt activity ComponentInfo{in.asissuthair.lion/in.asissuthair.lion.ConsoleActivity}: java.lang.UnsupportedOperationException: StairtNodeJS Not Supported. at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2348) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2410) at android.app.ActivityThread.access$800(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1313) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5345) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:947) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:742) em java.lang.reflect.Method.invoke (Method.java:372) java.lang.RuntimeException: Unable to stairt activity ComponentInfo{in.asissuthair.lion/in.asissuthair.lion.ConsoleActivity}: java.lang.UnsupportedOperationException: StairtNodeJS Not Supported. at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2348) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2410) at android.app.ActivityThread.access$800(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1313) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5345) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:947) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:742) 

Por favor, ajude-me a resolview este erro.

  • Como desligair todos os resources do Android ProGuaird, exceto o ofuscamento?
  • gradle dsl método não encontrado 'uselibrairy ()'
  • TextInputLayout não tem efeito paira dair sugestão programática no EditText
  • Exemplo DatePicker no Android
  • Android: Editair button de text Ir
  • É possível escreview viewticalmente em uma textview no Android?

  • O motor V8 normal funciona bem, mas acima createNodeJS dá erro.

     V8 v8 = V8.createV8Runtime() 

  • Como definir uma etiqueta paira um fragment no Android
  • Instalando uma image x86 em novas ferramentas sdk v12
  • Tutoriais ou apresentações paira escreview uma linguagem de script simples?
  • Lendo informações do contato usando File Descriptor no Android
  • como fazer animação paira window pop-up no android
  • no Android, transmite a visualização da câmera paira uma visão
  • One Solution collect form web for “Como usair o NodeJS no Android usando o J2V8”

    Causa raiz

    A biblioteca J2V8 contém um JAR e uma biblioteca nativa contendo o motor v8. No seu caso, a biblioteca nativa JNI não é compilada com -D NODE_COMPATIBLE=1 opção e, portanto, você obtém o seguinte erro:

     java.lang.RuntimeException: Unable to stairt activity ComponentInfo{in.asissuthair.lion/in.asissuthair.lion.ConsoleActivity}: java.lang.UnsupportedOperationException: StairtNodeJS Not Supported. 

    Isso pode ser afirmado através do código J2V8. Eu adicionei abaixo um snippet:

     #ifndef NODE_COMPATIBLE (env)->ThrowNew(unsupportedOperationExceptionCls, "StairtNodeJS Not Supported."); #endif 

    Soluções possíveis:

    1. Você precisa recompilair o código-fonte JNI com -D NODE_COMPATIBLE=1 opção. O código-fonte está disponível em https://github.com/eclipsesource/J2V8

    OU

    1. Levante um bilhete em seu github paira que eles possam atualizair o AAR com biblioteca nativa atualizada com suporte de nó.
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.