Groovy CompileStatic on Android goes bad Groovy True

In Groovy, you can check collections for empty and empty simply by placing this variable inside yourself if you want:

def collection = [ 'test' ] if(!collection) { //Collection is either null or empty, handle exceptional business here } 

However, when placing @CompileStatic in a class that contains such code, it stops working (but only on Android) with an error:

 02-16 20:49:03.837: E/AndroidRuntime(9013): org.codehaus.groovy.runtime.metaclass.MissingMethodExceptionNoStack: No signature of method: java.util.ArrayList.asBoolean() is applicable for argument types: () values: [] 

This is not like starting the desktop version.

To provide more context. This is a generated LibGDX project with three projects (-core, -desktop, -android), where the -core project was converted to a Groovy project. The -core project is referenced, and the dependencies of the -desktop and -android projects

The desktop version works without any problems, regardless of whether classes annotated with @CompileStatic and Groovy annotations @CompileStatic True is properly recognized.

On android, on the other hand, the above error occurs.

I do not use the grooid library because the project that was converted to Groovy is shared between both desktop and Android.

If it costs, here is the content of build.gradle at the project level:

 buildscript { repositories { mavenCentral() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.0.0' classpath 'org.codehaus.groovy:gradle-groovy-android-plugin:0.3.5' } } allprojects { apply plugin: "eclipse" apply plugin: "idea" version = '1.0' ext { appName = 'CastleShuffle' gdxVersion = '1.5.4' roboVMVersion = '1.0.0-beta-04' box2DLightsVersion = '1.3' ashleyVersion = '1.3.1' aiVersion = '1.5.0' } repositories { mavenCentral() jcenter() maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } maven { url "https://oss.sonatype.org/content/repositories/releases/" } } } project(":desktop") { apply plugin: "java" dependencies { compile project(":core") compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion" compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop" compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop" compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop" } } project(":android") { apply plugin: "android" //apply plugin: "groovyx.grooid.groovy-android" configurations { natives } dependencies { compile project(":core") compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion" natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi" natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a" natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86" compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion" natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi" natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a" natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86" compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion" natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi" natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a" natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86" // compile 'org.codehaus.groovy:groovy:2.4.0:grooid' //Adding this causes a Dex exception where groovy class Bindable is referenced multiple times // compile 'org.codehaus.groovy:groovy-all:2.4.0' } } project(":core") { apply plugin: "groovy" dependencies { compile 'org.codehaus.groovy:groovy-all:2.4.0' compile "com.badlogicgames.gdx:gdx:$gdxVersion" compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion" compile "com.badlogicgames.gdx:gdx-freetype:$gdxVersion" } } tasks.eclipse.doLast { delete ".project" } 
+7
android groovy libgdx truthiness
source share
1 answer

You need to use the groovy version of Groovy for all of your modules, otherwise you will have generated code that uses a runtime that targets regular JVMs. Using "2.4.1-grooid" for all of your modules should be good, I think.

+4
source share

All Articles