Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is Android supported now? #403

Closed
hsluoyz opened this issue Jul 26, 2021 · 21 comments
Closed

Is Android supported now? #403

hsluoyz opened this issue Jul 26, 2021 · 21 comments

Comments

@hsluoyz
Copy link

hsluoyz commented Jul 26, 2021

@killme2008 hi, I'm from Casbin community. Casbin uses aviator as evaluation engine and a user reported that aviator doesn't support Android in: casbin/jcasbin#214 . When can the support be added? Thanks for the contribution!

@killme2008
Copy link
Owner

Sorry, i don't have time to do it.

@hsluoyz
Copy link
Author

hsluoyz commented Jul 27, 2021

@killme2008 can you give us some suggestions like which parts need to be fixed to support Android? We may have some developers to work on this.

@killme2008
Copy link
Owner

@hsluoyz I will implement it in 5.3 version.

@killme2008
Copy link
Owner

killme2008 commented Sep 12, 2021

@hsluoyz hi, i am implementing interpreter mode in #412 .

It's almost completed right now, can you help me to try it on android platform?

You can create a script engine in interpreter mode by :

AviatorEvaluatorInstance engine = AviatorEvaluator.newInstance(EvalMode.INTERPRETER);

Then use the instance as a normal engine as before.

@killme2008
Copy link
Owner

killme2008 commented Sep 12, 2021

Of course, the default(global) script engine will try to detect if it's running on android platform , then use interpreter mode by default.

@hsluoyz
Copy link
Author

hsluoyz commented Sep 12, 2021

@killme2008 thanks for supporting Android!

@tangyang9464 can you try this solution?

@tangyang9464
Copy link

@hsluoyz @killme2008 I'll do it

@killme2008
Copy link
Owner

@tangyang9464 If you have any test result or issues, please let me known. I will release a beta version ASAP.

@tangyang9464
Copy link

tangyang9464 commented Sep 13, 2021

@tangyang9464 If you have any test result or issues, please let me known. I will release a beta version ASAP.

@killme2008 I tested it briefly and compared with the previous version, at least it can now run successfully on the Android platform.
And it can works with or without EvalMode.INTERPRETER

@killme2008
Copy link
Owner

@tangyang9464 yep, it will detect if it's running on andorid platform, if so, then use interpreter by default.

@tangyang9464
Copy link

@killme2008 ok,waiting for the beta release version. We will test it in our application later.

@killme2008
Copy link
Owner

I released 5.3.0-beta , you can test it right now, thank you. @tangyang9464

@tangyang9464
Copy link

tangyang9464 commented Sep 15, 2021

@killme2008 I test the 5.3.0-beta, but it reported an error. The code just AviatorEvaluatorInstance engine = AviatorEvaluator.newInstance(EvalMode.INTERPRETER);

java.lang.ExceptionInInitializerError
        at com.googlecode.aviator.AviatorEvaluator$StaticHolder.access$000(AviatorEvaluator.java:100)
        at com.googlecode.aviator.AviatorEvaluator.getInstance(AviatorEvaluator.java:112)
        at com.googlecode.aviator.AviatorEvaluator.<clinit>(AviatorEvaluator.java:61)
        at com.googlecode.aviator.AviatorEvaluator.newInstance(AviatorEvaluator.java:88)
        at com.example.android.testing.ServiceTestRuleSample.LocalService.getRandomInt(LocalService.java:74)
        at com.example.android.testing.ServiceTestRuleSample.LocalServiceTest.testWithBoundService(LocalServiceTest.java:75)
        at java.lang.reflect.Method.invoke(Native Method)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
        at androidx.test.rule.ServiceTestRule$ServiceStatement.evaluate(ServiceTestRule.java:337)
        at org.junit.rules.RunRules.evaluate(RunRules.java:20)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
        at androidx.test.ext.junit.runners.AndroidJUnit4.run(AndroidJUnit4.java:162)
        at org.junit.runners.Suite.runChild(Suite.java:128)
        at org.junit.runners.Suite.runChild(Suite.java:27)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
        at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:56)
        at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:453)
        at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2205)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'com.googlecode.aviator.Options$Value com.googlecode.aviator.AviatorEvaluatorInstance.getOptionValue(com.googlecode.aviator.Options)' on a null object reference
        at com.googlecode.aviator.runtime.RuntimeUtils.isTracedEval(RuntimeUtils.java:124)
        at com.googlecode.aviator.code.interpreter.InterpretContext.<init>(InterpretContext.java:36)
        at com.googlecode.aviator.InterpretExpression.loadConstants(InterpretExpression.java:50)
        at com.googlecode.aviator.InterpretExpression.<init>(InterpretExpression.java:40)
        at com.googlecode.aviator.code.interpreter.InterpretCodeGenerator.getResult(InterpretCodeGenerator.java:359)
        at com.googlecode.aviator.code.OptimizeCodeGenerator.getResult(OptimizeCodeGenerator.java:438)
        at com.googlecode.aviator.code.LambdaGenerator.getResult(LambdaGenerator.java:424)
        at com.googlecode.aviator.code.LambdaGenerator.getLmabdaBootstrap(LambdaGenerator.java:189)
        at com.googlecode.aviator.code.OptimizeCodeGenerator.onLambdaBodyEnd(OptimizeCodeGenerator.java:783)
        at com.googlecode.aviator.code.LambdaGenerator.onLambdaBodyEnd(LambdaGenerator.java:472)
        at com.googlecode.aviator.parser.ExpressionParser.ifStatement(ExpressionParser.java:1916)
        at com.googlecode.aviator.parser.ExpressionParser.statement(ExpressionParser.java:1627)
        at com.googlecode.aviator.parser.ExpressionParser.statements(ExpressionParser.java:1853)
        at com.googlecode.aviator.parser.ExpressionParser.forStatement(ExpressionParser.java:1789)
        at com.googlecode.aviator.parser.ExpressionParser.statement(ExpressionParser.java:1634)
        at com.googlecode.aviator.parser.ExpressionParser.statements(ExpressionParser.java:1853)
        at com.googlecode.aviator.parser.ExpressionParser.lambda(ExpressionParser.java:793)
        at com.googlecode.aviator.parser.ExpressionParser.fnStatement(ExpressionParser.java:1265)
        at com.googlecode.aviator.parser.ExpressionParser.statement(ExpressionParser.java:1656)
        at com.googlecode.aviator.parser.ExpressionParser.statements(ExpressionParser.java:1835)
        at com.googlecode.aviator.parser.ExpressionParser.parse(ExpressionParser.java:1106)
        at com.googlecode.aviator.parser.ExpressionParser.parse(ExpressionParser.java:1120)
        at com.googlecode.aviator.AviatorEvaluatorInstance.innerCompile(AviatorEvaluatorInstance.java:1513)
        at com.googlecode.aviator.AviatorEvaluatorInstance.compile(AviatorEvaluatorInstance.java:1474)
        at com.googlecode.aviator.AviatorEvaluatorInstance.compile(AviatorEvaluatorInstance.java:1432)
        at com.googlecode.aviator.AviatorEvaluatorInstance.loadInternalFunctions(AviatorEvaluatorInstance.java:1053)
        at com.googlecode.aviator.AviatorEvaluatorInstance.loadInternalLibs(AviatorEvaluatorInstance.java:1037)
        at com.googlecode.aviator.AviatorEvaluatorInstance.loadLib(AviatorEvaluatorInstance.java:902)
        at com.googlecode.aviator.AviatorEvaluatorInstance.<init>(AviatorEvaluatorInstance.java:1091)
        at com.googlecode.aviator.AviatorEvaluator$StaticHolder.<clinit>(AviatorEvaluator.java:102)

I used yours feature/interpreter before and it can works.

@killme2008
Copy link
Owner

sorry, i don't have an android environment to test it. It's a bug here, i will fix it ASAP.

@killme2008
Copy link
Owner

Fixed in 797abed

Try to release beta2

@killme2008
Copy link
Owner

Released 5.3.0-beta2. https://repo1.maven.org/maven2/com/googlecode/aviator/aviator/5.3.0-beta2/

Thank you for your test.

@killme2008
Copy link
Owner

@tangyang9464 have you tried beta2? any problems?

@tangyang9464
Copy link

@killme2008 No problems for now

@killme2008
Copy link
Owner

killme2008 commented Oct 15, 2021

@tangyang9464 hi, Did you found any problems in 5.3.0-beta2 version running on android? If not, i will release 5.3.0 ASAP.

@tangyang9464
Copy link

@killme2008 No bugs have been reported so far. I think it can be released

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants