rhino-android
rhino-android copied to clipboard
Proguard problems
I'm using proguard and cannot create engine using this code:
ScriptEngineManager().getEngineByName("rhino")
The string above always return null.
I have added these rules into my proguard-rules.pro
file:
-keep class org.mozilla.** { *; }
-keep class com.sun.script.** { *; }
-keep class sun.** { *; }
-keep class javax.** { *; }
-keep class apple.** { *; }
-keep class jdk.nashorn.** { *; }
-keepattributes Signature
-dontwarn org.mozilla.javascript.**
-dontwarn org.mozilla.classfile.**
Do you know how to fix? I have added your proguard config,but it still return null.
@sunflowerseat nope. These rules didn't help me too. I decided to use another library:
implementation group: 'org.mozilla', name: 'rhino', version: '1.7.10'
You'll need to change your code slightly.
Mine looks like this:
val mozillaContext = org.mozilla.javascript.Context.enter()
mozillaContext.optimizationLevel = -1
val scope: Scriptable = mozillaContext.initStandardObjects()
val result = mozillaContext.evaluateString(scope, formula, "<cmd>", 1, null).toString()