【问题标题】:Annotation Processors Must Be Explicitly Decalred Now注释处理器现在必须显式标记
【发布时间】:2018-03-03 04:13:33
【问题描述】:

我在我的 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'
}

【问题讨论】:

标签: android annotations android-glide


【解决方案1】:

不需要使用 glide 作为 jar 库。

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

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

添加此代码。

repositories {
  mavenCentral()
  google()
}

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

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

希望对你有帮助。

【讨论】:

  • 我删除了这些(jar)仍然相同的错误并尝试了你的方法都不起作用
【解决方案2】:

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

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

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

【讨论】:

    【解决方案3】:

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

    还要确保删除 libs 文件夹中 Glide .jar 文件的所有本地副本。我有一种感觉 https://stackoverflow.com/a/49080598/253468 没用,因为您仍在使用原来有问题的使用库的方式;一般来说,对于 Android,您不必使用 libs 文件夹,生态系统已经足够成熟,可以拥有 jcenter/mavenCentral 发布的库。

    【讨论】:

      【解决方案4】:

      图书馆有一些问题,所以我决定Picasso 反对它。

      【讨论】:

        【解决方案5】:

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

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

        【讨论】:

        • 此选项已弃用,将来将被删除
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-08-17
        • 2014-03-11
        • 1970-01-01
        • 1970-01-01
        • 2013-05-27
        • 2023-03-04
        相关资源
        最近更新 更多