我创建了一个全新的Android项目并添加了lombok支持。
当我在Java 7上开发时,一切都运行良好,但是我将语言级别更新为8,lombok编译器停止运行。
我在gradle中为将语言更新为java 8所做的更改是:
jackOptions {
enabled true
}
和
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
我的朋友是:
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.instatrivia"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
jackOptions {
enabled true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
buildToolsVersion '25.0.0'
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support.constraint:constraint-layout:1.0.1'
testCompile "junit:junit:$rootProject.junitVersion"
// Android support libs
compile "com.android.support:appcompat-v7:$rootProject.supportLibraryVersion"
compile "com.android.support:cardview-v7:$rootProject.supportLibraryVersion"
compile "com.android.support:design:$rootProject.supportLibraryVersion"
compile "com.android.support:recyclerview-v7:$rootProject.supportLibraryVersion"
compile "com.android.support:support-v4:$rootProject.supportLibraryVersion"
// dagger
compile "com.google.dagger:dagger:$rootProject.dagger_version"
annotationProcessor "com.google.dagger:dagger-compiler:$rootProject.dagger_version"
// testApt "com.google.dagger:dagger-compiler:$rootProject.dagger_version"
// rx java/android
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
// Because RxAndroid releases are few and far between, it is recommended you also
// explicitly depend on RxJava's latest version for bug fixes and new features.
compile 'io.reactivex.rxjava2:rxjava:2.0.1'
provided 'javax.annotation:jsr250-api:1.0'
compile 'javax.inject:javax.inject:1'
// misc
provided "org.projectlombok:lombok:1.16.14"
compile "com.google.guava:guava:$rootProject.guavaVersion"
compile "com.squareup.retrofit2:retrofit:$rootProject.retrofitVersion"
compile "com.squareup.retrofit2:converter-gson:$rootProject.retrofitVersion"
compile 'com.google.code.gson:gson:2.2.4'
compile 'org.greenrobot:eventbus:3.0.0'
compile 'com.jakewharton.timber:timber:4.5.1'
compile 'com.jakewharton:butterknife:8.5.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
}
我在构建期间遇到的错误是:
Warning:You aren't using a compiler supported by lombok, so lombok will not work and has been disabled.
Your processor is: com.android.jack.eclipse.jdt.internal.compiler.apt.dispatch.BatchProcessingEnvImpl
Lombok supports: sun/apple javac 1.6, ECJ
答案 0 :(得分:0)
您不能同时拥有jack
和lombok
,因此您需要选择更多内容。
除非你真的需要它,否则可以接受jack
(现在无论如何都是announced dead),因为某些Java 8功能可以用外部库替换(即Lambda用{{3 }})。