Butterknife gradle error on Android Studio 3.0 due to android-apt plugin

孤街醉人 提交于 2019-12-12 10:54:04

问题


After upgrading to Android Studio 3.0 I had some issues with gradle that I was able to fix checking on the developers website

However, I was not able to find how to fix the issue with the apply plugin: 'android-apt' I have tried several things such as removing it from the project gradle and add it to the app gradle as annotationProcessor 'com.neenbedankt.gradle.plugins:android-apt:1.8' . also removed the apt, etc, etc.

Anyway, Studio is complaining about it. Any help is greatly appreciated. Thanks!

    // Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
        classpath 'com.google.gms:google-services:3.1.1'

    }
}

allprojects {
    repositories {
        jcenter()
        google()
        maven { url "https://jitpack.io" }
    }

    ext {
        supportLibVersion = '27.0.0'
        firebaseLibVersion = '11.4.2'
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

APP GRADLE

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.0"
    defaultConfig {
        applicationId "xxxxxxxxxxxxxxxxxxxx"
        minSdkVersion 17
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"

        vectorDrawables.useSupportLibrary = true

    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    apply plugin: 'android-apt'
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')

    compile "com.android.support:appcompat-v7:${supportLibVersion}"
.....

    compile 'com.google.android.gms:play-services-auth:11.4.2'

    compile 'com.jakewharton:butterknife:8.4.0'
    apt 'com.jakewharton:butterknife-compiler:8.4.0'

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

回答1:


Do not use apt plugin, add the dependency like this:

compile "com.jakewharton:butterknife:8.8.1"
annotationProcessor "com.jakewharton:butterknife-compiler:8.8.1"

Reference




回答2:


If you are in hurry you can disable that thing.

As per Document

If you are experiencing issues migrating to the new dependency resolution strategy, you can restore behavior to that of Android plugin 2.3.0 by setting includeCompileClasspath true. However, restoring behavior to version 2.3.0 is not recommended.

android {
    ...
    defaultConfig {
        ...
        javaCompileOptions {
            annotationProcessorOptions {
                includeCompileClasspath false
            }
        }
    }
}

And one more thing you have to define flavorDimensions "default" property in buildTypes tag in gradle file.

You can check more about this here.



来源:https://stackoverflow.com/questions/46955653/butterknife-gradle-error-on-android-studio-3-0-due-to-android-apt-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!