【问题标题】:Error:android-apt plugin is incompatible with the Android Gradle plugin. Please use 'annotationProcessor' configuration instead, issue?错误:android-apt 插件与 Android Gradle 插件不兼容。请改用“annotationProcessor”配置,问题?
【发布时间】:2018-01-20 05:32:06
【问题描述】:

我遇到了一个错误:android-apt 插件与 Android Gradle 插件不兼容。请改用“annotationProcessor”配置,我使用的是 Android Studio 3.0.1,并且使用了可能 2 或 3 年的 Android Studio 项目,我已经尝试了所有方法,但找不到解决方案。 虽然已经搜索了整个网络但仍然没有运气解决它,而且我在 build.gradle 中的代码上没有看到任何 android-apt 插件

Build.Gradle 代码

    apply plugin: 'com.android.application'
apply plugin: 'realm-android'

android {
    compileSdkVersion 24
    buildToolsVersion '26.0.2'

    defaultConfig {
        applicationId "com.app.baryalitob"
        minSdkVersion 14
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

/* IMPORTANT :
 * Be careful when update dependencies, different version library may caused error */
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    // google library
    compile 'com.android.support:appcompat-v7:24.1.1'
    compile 'com.android.support:cardview-v7:24.1.1'
    compile 'com.android.support:recyclerview-v7:24.1.1'
    compile 'com.android.support:design:24.1.1'
    compile 'com.android.support:support-v4:24.1.1'
    compile 'com.google.android.gms:play-services-ads:9.2.1'
    compile 'com.google.android.gms:play-services-analytics:9.2.1'
    compile 'com.google.firebase:firebase-messaging:9.2.1'

    // library for api
    compile('com.squareup.retrofit2:retrofit:2.0.0-beta4') {
        exclude module: 'okhttp'
    }
    compile 'com.squareup.okhttp3:okhttp:3.2.0'
    compile 'com.squareup.okhttp3:logging-interceptor:3.0.1'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    compile 'com.squareup.picasso:picasso:2.5.2'

    // ripple effect library
    compile 'com.balysv:material-ripple:1.0.2'
}

apply plugin: 'com.google.gms.google-services'

【问题讨论】:

标签: javascript java android


【解决方案1】:

您应该从构建级别的 gradle 中删除 apply plugin: 'com.neenbedankt.android-apt' 或者如果问题仍然存在,请尝试删除一些第三方库。您在代码中使用的任何库都可能会使用它。

【讨论】:

  • 能否请您更具体一些,因为我是新手,如果您能提供一些更简短的深度说明会很棒?
【解决方案2】:

我遇到了与在 macOS 10.13 上使用 Android Studio 3.1 相同的问题。

我这里尝试在两个文件中修改gradle版本:

1.gradle-wrapper.properties

distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip

distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip

2.build.gradle(Module: app)

classpath 'com.android.tools.build:gradle:3.1.0'

classpath 'com.android.tools.build:gradle:2.1.2'

然后我解决了这个问题。

【讨论】:

  • 我不得不降级我的 android studio 的版本,所以它确实可以工作,但这只是一个临时解决方案,因为我们必须使用更高的更新版本,暂时解决了。
  • @AzizKhan 你说得对,这是临时解决方案,有时它真的很有用。我们需要找到另一个更好的解决方案。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-01-26
  • 2018-08-07
  • 1970-01-01
  • 2015-11-25
  • 2017-05-29
相关资源
最近更新 更多