Butterknife: Android Gradle plugin 3.1.0 must not be applied to project '/Users/android_package/butterKnife/app' since version 3.1.0 was already applied to this project

Created on 9 Jun 2018  ·  6Comments  ·  Source: JakeWharton/butterknife

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

buildscript {

repositories {
    google()
    jcenter()
    mavenCentral()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.2'
    classpath 'com.jakewharton:butterknife-gradle-plugin:8.8.1'// here

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

}

allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}

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


apply plugin: 'com.android.application'
apply plugin: 'com.android.library' // here
apply plugin: 'com.jakewharton.butterknife' // here
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.chl.butterknife"
minSdkVersion 16
targetSdkVersion 27
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(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
testImplementation 'junit:junit:4.12'
implementation 'com.jakewharton:butterknife:8.8.1' // here
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1' // here
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

```

How to solve?

Most helpful comment

I think you have to use either apply plugin: 'com.android.application' or
apply plugin: 'com.android.library'. As far as I know, you can't use both

All 6 comments

https://blog.csdn.net/yechaoa/article/details/78363911 照着这篇博文,亲测可以!

遇到同样问题,请问怎么解决

Is your project a library ?

I have the same issue how do I solve this issue? My error is
ERROR: Android Gradle plugin 3.5.3 must not be applied to project '/Users/gauri/Documents/code/TestingLayout/app' since version 3.5.3 was already applied to this project

Same issue except its pointing to 3.5.0.

I think you have to use either apply plugin: 'com.android.application' or
apply plugin: 'com.android.library'. As far as I know, you can't use both

Was this page helpful?
0 / 5 - 0 ratings