注释处理器现在必须明确标示

Annotation Processors Must Be Explicitly Decalred Now

我在 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.

Gradle:

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库使用

只需使用它的依赖项...

在项目-> build.gradle文件中:

添加此代码。

repositories {
  mavenCentral()
  google()
}

在应用 build.gradle 文件中: 添加此代码。

dependencies {
  implementation 'com.github.bumptech.glide:glide:4.6.1'
  annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
}

希望对您有所帮助。

图书馆出了点问题所以我决定 Picasso 反对。

只需阅读安装说明并按照说明操作(如果您的 Gradle 版本允许,请使用 implementation 而不是 compile): http://bumptech.github.io/glide/doc/download-setup.html#gradle

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

在应用 build.gradle 文件中:添加此代码:

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

我在尝试使用 glide 时遇到了这个问题。 如果你正在使用 Kotlin。你应该添加这个

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

查看此处的说明http://bumptech.github.io/glide/doc/download-setup.html#gradle