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

When importing a project into studio, the following error will occasionally be reported

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.

I also post a picture of the error report here. It’s a direct screenshot. It doesn’t look very clear. You can double-click to open the picture.
Insert image description here

Modification :
Add the following part to the app's 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