You need to connect Rhino (JavaScript interpreter) to the application on Android. Gradle is used, the dependency is added without problems:

dependencies { ... compile "org.mozilla:rhino:1.7.7.2" } 

The problem is that Rhino contains the "tools" package (org.mozilla.javascript.tools), which uses javax.swing classes that are absent on Android, which is why ProGuard swears and does not allow building the application find common super class ... "for a class that uses javax.swing.JInternalFrame and is in an unnecessary package" tools ").

Is it possible to somehow exclude this package from a dependency? Make it so that it is simply ignored during the build and does not end up in the resulting application.

Rhino dependency structure, tools package is highlighted, which should be ignored

The same question was asked on the Gradle forum, but there were no answers: Exclude package from dependency / runtime repackage dependency

In search of a solution I tried the options:

 compile ("org.mozilla:rhino:1.7.7.2") { exclude group: 'org.mozilla.javascript.tools' } 

and

 sourceSets { main { java { exclude 'org/mozilla/javascript/tools/**' } } } 

but to no avail.

    1 answer 1

    You must either look for an assembly without this package, or make it yourself by downloading the source code.

    Or here: https://github.com/F43nd1r/rhino-android

    • In other words, using Gradle is it definitely impossible to do? - therainycat
    • Maybe there is a plugin that will repackage dependency, cutting the package. But I can not advise anything concrete. - Eugene Krivenja