在Library中使用jack編譯

來自StackoverFlow的搬運工:
http://stackoverflow.com/questions/37975128/is-there-way-to-use-java-8-features-with-android-library-project/38360596#38360596
在library gradle中配置:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.2'
    }
}
apply plugin: 'com.android.library'

repositories {
    mavenCentral()
}

// Java8 not fully supported in library projects yet, https://code.google.com/p/android/issues/detail?id=211386
// this is a temporary workaround to get at least lambdas compiling
gradle.projectsEvaluated {
    tasks.withType(JavaCompile) {
        options.compilerArgs << "-Xbootclasspath/a:" + System.properties.get("java.home") + "/lib/rt.jar"
    }
}

android {
    compileSdkVersion 24
    buildToolsVersion "24"

    defaultConfig {
        minSdkVersion 10
        targetSdkVersion 24
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章