Android 注释处理器现在必须显式标记

Android 注释处理器现在必须显式标记,android,annotations,android-glide,Android,Annotations,Android Glide,我在我的Android中添加了以下库,之后我发现了错误 错误: 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

我在我的Android中添加了以下库,之后我发现了错误

错误:

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.
    - compiler-4.6.1.jar (compiler-4.6.1.jar)   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.
apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.usamaakmal.bookswap"
        minSdkVersion 21
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        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:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:support-v4:26.1.0'
    implementation 'com.android.support:design:26.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    compile 'com.squareup.retrofit2:retrofit:2.3.0'
    compile 'com.squareup.retrofit2:converter-gson:2.3.0'
    compile 'com.google.code.gson:gson:2.7'
    compile 'com.jaredrummler:material-spinner:1.2.4'
    compile 'com.mikhaellopez:circularimageview:3.0.2'
    implementation 'com.android.support:cardview-v7:26.1.0'
}
Gradle:

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.
    - compiler-4.6.1.jar (compiler-4.6.1.jar)   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.
apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.example.usamaakmal.bookswap"
        minSdkVersion 21
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        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:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:support-v4:26.1.0'
    implementation 'com.android.support:design:26.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    compile 'com.squareup.retrofit2:retrofit:2.3.0'
    compile 'com.squareup.retrofit2:converter-gson:2.3.0'
    compile 'com.google.code.gson:gson:2.7'
    compile 'com.jaredrummler:material-spinner:1.2.4'
    compile 'com.mikhaellopez:circularimageview:3.0.2'
    implementation 'com.android.support:cardview-v7:26.1.0'
}

无需将glide用作jar库

只要使用它的依赖性

在project->build.gradle文件中:

添加此代码

repositories {
  mavenCentral()
  google()
}
dependencies {
  implementation 'com.github.bumptech.glide:glide:4.6.1'
  annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
}
应用内build.gradle文件: 添加此代码

repositories {
  mavenCentral()
  google()
}
dependencies {
  implementation 'com.github.bumptech.glide:glide:4.6.1'
  annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
}

希望它能对您有所帮助。

图书馆有一些问题,所以我决定
与之相反。

只需阅读安装说明并按照说明操作即可(如果您的Gradle版本允许,请使用
实现
而不是
编译
):


还要确保删除
libs
文件夹中Glide.jar文件的所有本地副本。我有一种感觉,因为你仍然使用最初有问题的方式来使用图书馆,所以没有起作用;一般来说,对于Android,您不必使用
libs
文件夹,生态系统已经足够成熟,可以发布jcenter/mavenCentral库。

in-App build.gradle文件:添加以下代码:

android {
    ...
    defaultConfig {
       ...
       javaCompileOptions { annotationProcessorOptions { includeCompileClasspath = true } }
    }
}

我在尝试使用glide时遇到了这个问题。 如果您使用的是Kotlin。你应该加上这个

dependencies {
  kapt 'com.github.bumptech.glide:compiler:4.9.0'
}

检查此处的说明

可能重复的I删除这些(jar)仍然相同的错误并尝试了您的方法两者都不工作此选项已弃用,将在将来删除