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

proguard problem about rhino in Android #540

Closed
currydou opened this issue May 5, 2019 · 6 comments
Closed

proguard problem about rhino in Android #540

currydou opened this issue May 5, 2019 · 6 comments
Labels
Android Issues related to running Rhino on Android

Comments

@currydou
Copy link

currydou commented May 5, 2019

compile 'io.apisense:rhino-android:1.0'

TextView resultTextView = findViewById(R.id.result_text_view);
String currentText = resultTextView.getText().toString();
boolean valid = checkForValidity();
double result=0;
if(valid){
ScriptEngine engine = new ScriptEngineManager().getEngineByName("rhino");
try{
result = (double)engine.eval(currentText);
}catch(Exception e){
Toast.makeText(this,"Exception Raised",Toast.LENGTH_SHORT).show();
}
currentText = currentText +"\n"+ "="+(result);
}
resultTextView.setText(currentText);

NullPointerException after proguard

Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.Object javax.script.ScriptEngine.eval(java.lang.String)' on a null object reference

i tried these.But failed.
-keep class org.mozilla.** { ; }
-keep class javax.script.
* { *; }

@gbrail
Copy link
Collaborator

gbrail commented May 6, 2019

I don't have proguard or know much about it.

I do know that "rhino" was a supported script engine in old versions of Java, but it hasn't been for a while. So it's likely that "getEngineByName" is correctly returning null.

@PragyaSingla
Copy link

I am getting same issue after proguard. Getting null pointer exception while evaluating engine

val engine = ScriptEngineManager().getEngineByName("javascript")
engine.eval("") // at line line

@p-bakker p-bakker added the Android Issues related to running Rhino on Android label Jul 2, 2021
@tonygermano
Copy link
Contributor

tonygermano commented Jul 2, 2021

I don't think this issue is related to anything in this repository.

https://github.com/APISENSE/rhino-android

This mentions at the bottom of the README that Proguard will cause issues with ScriptEngine.

@tonygermano
Copy link
Contributor

I think this issue can be closed as it is basically half of the issues opened against the APISENSE/rhino-andriod repository.

APISENSE/rhino-android#1
APISENSE/rhino-android#4
APISENSE/rhino-android#8
APISENSE/rhino-android#10
APISENSE/rhino-android#11

The workaround in issue 10 is to use Rhino directly instead of the apisense ScriptEngine with Proguard.

@tonygermano
Copy link
Contributor

And APISENSE/rhino-android#8 (comment) indicates it was resolved by an Andriod SDK update.

@p-bakker
Copy link
Collaborator

p-bakker commented Jul 2, 2021

Assuming resolved as per comments by @tonygermano

@p-bakker p-bakker closed this as completed Jul 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android Issues related to running Rhino on Android
Projects
None yet
Development

No branches or pull requests

5 participants