Carsten Hagemann
Carsten Hagemann

Reputation: 1144

InvokeDynamic not supported when building for Android

I'm running Gluon/charm version 3.0.0. I added a Java8-compiled library into my JavaFX project (created via the IntelliJ plugin) and on iOS it works and builds as expected, but when executing the gradle tasks android or androidInstall I get this error back:

[ant:java] Java Result: 1
:createMainDexList FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':createMainDexList'.
> Exception in thread "main" com.android.dx.cf.iface.ParseException: InvokeDynamic not supported
    at com.android.dx.cf.cst.ConstantPoolParser.determineOffsets(ConstantPoolParser.java:226)
    at com.android.dx.cf.cst.ConstantPoolParser.parse(ConstantPoolParser.java:132)
    at com.android.dx.cf.cst.ConstantPoolParser.parseIfNecessary(ConstantPoolParser.java:124)
    at com.android.dx.cf.cst.ConstantPoolParser.getPool(ConstantPoolParser.java:115)
    at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:491)
    at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
    at com.android.dx.cf.direct.DirectClassFile.parseToEndIfNecessary(DirectClassFile.java:397)
    at com.android.dx.cf.direct.DirectClassFile.getAttributes(DirectClassFile.java:311)
    at com.android.multidex.MainDexListBuilder.hasRuntimeVisibleAnnotation(MainDexListBuilder.java:191)
    at com.android.multidex.MainDexListBuilder.keepAnnotated(MainDexListBuilder.java:167)
    at com.android.multidex.MainDexListBuilder.<init>(MainDexListBuilder.java:121)
    at com.android.multidex.MainDexListBuilder.main(MainDexListBuilder.java:91)
    at com.android.multidex.ClassReferenceListBuilder.main(ClassReferenceListBuilder.java:58)
...while preparsing cst 0002 at offset 0000000f
...while parsing de/<removed>/traffic_light/library/Test.class

What I find a bit weird is that I don't even have a Test class for traffic_light, not even in the library. Searching for the error I found that it probably needs Java 8 to invokeDynamic/Support Lambdas, but for example Gluon's Presenter itself uses Lambdas.

Also, googling I find this hit about the same issue but sadly Gluon removed their forum and the page isn't cached anywhere.

Upvotes: 2

Views: 2798

Answers (1)

Jos&#233; Pereda
Jos&#233; Pereda

Reputation: 45476

Typically this error happens when you add some third party dependencies to the project that use lambda expressions, since currently the retrolambda plugin is applied to the source code of your project only.

You can try:

  1. Remove that dependency and add its source code instead.

  2. Apply retrolambda to the original dependency, and then add it to your project.

  3. Or use the most recent jfxmobile plugin: the 1.0.10-SNAPSHOT will apply retrolambda to both the source code and the third party dependencies (even if no source code is provided).

For the last option, just change the jfxmobile plugin version on top of your build.gradle file:

buildscript {
    repositories {
        jcenter()
        maven {
            url "https://oss.sonatype.org/content/repositories/snapshots/"
        }
    }
    dependencies {
        classpath 'org.javafxports:jfxmobile-plugin:1.0.10-SNAPSHOT'
    }
}

Upvotes: 7

Related Questions