简体   繁体   中英

Java 8 Build Error in Gradle

I'm trying to use JGraphT on Android because I can't seem to find any other decent graph algorithms library in Java (recommendations welcome, I've tried Erdos and it didn't suit my needs). There's a lack of documentation in the repository, but this is what I tried doing to get it to install:

build.gradle (Module: app)

android {
    ...
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    ...
}

dependencies {
    ...
    compile 'org.jgrapht:jgrapht-core:1.0.1'
    ...
}

I know that JGraphT uses Java 8 and that the latest version of Android Studio (2.3.3) includes the Jack compiler. However, I am getting the following error when I try to build the project.

Error:Execution failed for task ':app:transformClassesWithPreJackPackagedLibrariesForDebug'.
> com.android.sched.scheduler.RunnerProcessException: Error during 'TypeLegalizer' runner on 'private final synthetic int org.jgrapht.alg.vertexcover.-$Lambda$71.$m$0(java.lang.Object arg0)': Unexpected error during visit: com.android.jack.ir.ast.JReturnStatement at "Unknown source info"

This looks like some sort of Java 8 compilation issue, but I have no idea how to go about fixing it.

Jack still does not support all java 8 features. For a how-to see Java 8 Language Features | Android Developers . And it's already deprecated :

We've decided to add support for Java 8 language features directly into the current javac and dx set of tools, and deprecate the Jack toolchain.

So unfortunately it's impossible compile Java 8 libraries now

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM