rhino-android icon indicating copy to clipboard operation
rhino-android copied to clipboard

Proguard problems

Open Skullper opened this issue 4 years ago • 2 comments

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.**

Skullper avatar Mar 04 '20 07:03 Skullper

Do you know how to fix? I have added your proguard config,but it still return null.

sunflowerseat avatar Apr 23 '20 08:04 sunflowerseat

@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()

Skullper avatar Apr 23 '20 15:04 Skullper