1

I use JEXL library in my app and it seems like the new Android class shrinker fails to process it.

Here is my dependency:

compile 'org.apache.commons:commons-jexl:2.1.1'

My build type is defined as follows:

    debug {
        versionNameSuffix "-dev"
        minifyEnabled true
        useProguard false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }

And when I try to build it I get this error:

What went wrong: Execution failed for task ':app:transformClassesWithNewClassShrinkerForDebug'.
com.android.build.gradle.shrinker.ClassLookupException: Invalid class reference: javax/script/AbstractScriptEngine

Although it builds without any problems if I enable useProguard option or set both minifyEnabled and useProguard to false

I am aware that javax.script used by JEXL internally is not available on Android but the parts I use work pretty good so I have no problems with using this library except that. Lint also raises InvalidPackage type of error for that reason but it can be easily disabled and not hurt the build process.

Is it possible to make new shrinker ignore it and proceed to the next steps like Lint does?

Igor Bubelov
  • 5,154
  • 5
  • 25
  • 24

1 Answers1

0

JEXL library refers to javax.script.AbstractScriptEngine and a lot of other classes which are not part of the Android runtime (android.jar), so ProGuard warns that something might be broken. If you're sure that your application works anyway, you can specify lines below in proguard-android.txt

-dontwarn javax.script.**
-dontwarn org.apache.commons.logging.**
-dontwarn java.beans.**

Now, most of the warnings were gone, but after a lot of search I still have no idea on how to fix the last warning:

[proguard] Warning: org.apache.commons.jexl3.scripting.JexlScriptEngine: can't find referenced field 'javax.script.ScriptContext context' in class org.apache.commons.jexl3.scripting.JexlScriptEngine
Lcsky
  • 825
  • 1
  • 8
  • 17