groovy icon indicating copy to clipboard operation
groovy copied to clipboard

Android: Remove Invoke Dynamic Call

Open AndrewReitz opened this issue 7 years ago • 4 comments

Uses jarjar to remove org.codehaus.groovy.vmplugin.v7.IndyInterface which has a invoke dynamic call. This call causes android compilation to fail when targeting sdk level 26 or above but the minSdk is less than 26.

Fixes: GROOVY-8366

AndrewReitz avatar Nov 08 '17 20:11 AndrewReitz

Hi,

Is there anything new to the matter ? If I understand correctly, this issue blocks the evolution of the android-gradle-plugin

Is there anything we can do to help ? We actually need an update on the plugin for our application to still be compatible with older versions of Android.

chris-carneiro avatar Oct 09 '19 16:10 chris-carneiro

This is actually a big problem. For Groovy on the JVM there is no other way, than to more and more depend on invokedynamic. I think the suggestion of an Android version of Groovy is the best. But I wonder if that is really more than - I am not into Android development, so be patient with my ignorance - using for example D8 to ensure a certain API level compatibility.

blackdrag avatar Oct 10 '19 21:10 blackdrag

Thanks for the input. To my knowledge and as you guys previously outlined, the problem is - To quote google's documentation -

Desugar currently doesn't support MethodHandle.invoke or MethodHandle.invokeExact. If your source code or one of your module dependencies use one of these methods you need to specify minSdkVersion 26 or higher. Otherwise, you get the following error [...]

So yeah I guess D8 won't help, you're probably right on the best option suggestion. How hard would it be to implement an android version of Groovy, I'm really not familiar with the ways to port libraries.

chris-carneiro avatar Oct 11 '19 11:10 chris-carneiro

It could be as easy as using retrolambda to transform the Groovy library. Then, as long as you use pre Groovy 3 it should work - maybe even for classes generated with Groovy 3. For later versions you may have to transform the classes outputted by Groovy. But I strongly assume you are not trying to run scripts anyway.

blackdrag avatar Oct 11 '19 20:10 blackdrag