InvokeDynamic not supported when building for Android

若如初见. 提交于 2019-12-24 07:43:09

问题


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.


回答1:


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'
    }
}


来源:https://stackoverflow.com/questions/40080002/invokedynamic-not-supported-when-building-for-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!