Error:Execution failed for task ':app:javaPreCompileDebug'. > Annotation processors must be explicit

将工程导入studio时,偶尔会报以下错误

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.
    - butterknife-7.0.1.jar (com.jakewharton:butterknife:7.0.1)
  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.

在这里也贴上报错的图片,直接截的图,看着不太清楚,可以双击点击打开图片的
在这里插入图片描述

修改
在app的build.gradle中添加如下部分:

android {
    
    
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
    
    
        applicationId "com.sxwz.myapplication"
        minSdkVersion 18
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        
        //TODO 添加部分
        javaCompileOptions {
    
    
            annotationProcessorOptions {
    
    
                includeCompileClasspath true
            }
        }
    }
    buildTypes {
    
    
        release {
    
    
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

猜你喜欢

转载自blog.csdn.net/qq_42221857/article/details/102636645