错误:任务“:app:javaPreCompileDebug”的执行失败

时间:2018-06-21 19:00:47

标签: java android lombok

android 
{

compileSdkVersion 27
defaultConfig 

{

applicationId "downloader.video.full.videodownloader"

minSdkVersion 15

targetSdkVersion 27

versionCode 1

versionName "1.1"

useLibrary 'org.apache.http.legacy'

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}

buildTypes 

{


release 

{

minifyEnabled false

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-
rules.pro'

}

}

}

dependencies 

{

implementation fileTree(include: ['*.jar'], dir: 'libs')


implementation 'com.android.support:appcompat-v7:27.1.1'

implementation 'com.android.support.constraint:constraint-layout:1.1.2'

testImplementation 'junit:junit:4.12'

androidTestImplementation 'com.android.support.test:runner:1.0.2'

androidTestImplementation 'com.android.support.test.espresso:espresso-
core:3.0.2'

implementation 'com.io.tools.android.ramiloif.folderchooser:folderchooser-
dialog:1.0.6'

implementation 'com.google.android.gms:play-services-plus:10.0.1'

implementation 'com.google.android.gms:play-services-ads:10.0.1'

implementation 'com.android.support:design:27.1.1'

implementation files('libs/json-20140107.jar')

implementation 'com.squareup.okio:okio:1.14.1'

implementation 'com.squareup.picasso:picasso:2.71828'

compile 'com.google.android.gms:play-services-analytics:10.0.1'

} 

构建代码时出现此错误:

Error:Execution failed for task ':app:javaPreCompileDebug'.
> Annotation processors must be explicitly declared now.  The following dependencies on the compile classpath are found to contain annotation processor.  Please add them to the annotationProcessor configuration.
    - lombok-1.16.14.jar (org.projectlombok:lombok:1.16.14)
  Alternatively, set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true to continue with previous behavior.  Note that this option is deprecated and will be removed in the future.
  See https://developer.android.com/r/tools/annotation-processor-error-message.html for more details.

这是我的项目gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'



        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }

2 个答案:

答案 0 :(得分:1)

It tells you what to do...

> Annotation processors must be explicitly declared now.  The following dependencies on the compile classpath are found to contain annotation processor.  

> Please add them to the annotationProcessor configuration.  
      - lombok-1.16.14.jar (org.projectlombok:lombok:1.16.14)

Like so

    dependencies {

        // Other dependencies
        compileOnly "org.projectlombok:lombok:1.18.4"
        annotationProcessor 'org.projectlombok:lombok:1.18.4'
    }

[See Lombok documentation](https://projectlombok.org/setup/android)

Also, I suggest you delete `libs/json-20140107.jar` and replace it with 

    compile 'org.json:json:20140107'

Although, Android already has a JSON parser, so not clear why you need this at all

答案 1 :(得分:0)

只需将以下行添加到您的Module:app gradle文件中

dependencies {
    compileOnly "org.projectlombok:lombok:1.18.4"
    annotationProcessor 'org.projectlombok:lombok:1.18.4'
 }