为什么butterknife 9.0.0-SNAPSHOT无法解决?

Ism*_*ail 10 android butterknife androidx

我想使用AndroidX库,下面是Butterknife的Gradle设置

app:模块依赖

implementation 'com.jakewharton:butterknife:9.0.0-SNAPSHOT'
 annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-SNAPSHOT'
Run Code Online (Sandbox Code Playgroud)

插入

apply plugin: 'com.jakewharton.butterknife'

项目依赖

dependencies {
      classpath 'com.android.tools.build:gradle:3.3.0-alpha09'
      classpath 'com.google.gms:google-services:4.0.1'
      classpath 'com.jakewharton:butterknife-gradle-plugin:9.0.0-SNAPSHOT'
      // NOTE: Do not place your application dependencies here; they belong
      // in the individual module build.gradle files
    }
Run Code Online (Sandbox Code Playgroud)

项目存储库

repositories {
        google()
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
        jcenter()
    }
Run Code Online (Sandbox Code Playgroud)

Nab*_*ter 17

基于Naveen的答案,解决方案就在这里.
但是,缺少细节.请参阅以下Gradle配置以获取完整的解决方案:

...
dependencies {
    implementation 'com.jakewharton:butterknife:9.0.0-rc2'
    annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-rc2'
...
Run Code Online (Sandbox Code Playgroud)



buildscript {
    repositories {
        jcenter()
        google()
        maven { url "https://jitpack.io" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0-alpha10'
    }
}

allprojects {
    repositories {
        jcenter()
        google()
        maven { url "https://jitpack.io" }
        mavenCentral()
        maven {
            name 'Sonatype SNAPSHOTs';
            url 'https://oss.sonatype.org/content/repositories/snapshots/'
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)

基本上,不要使用apply plugin: 'com.jakewharton.butterknife'classpath 'com.jakewharton:butterknife-gradle-plugin:9.0.0-SNAPSHOT'来自这里的建议.

此外,此Android Studio设置>编译器配置: Android Studio设置>编译器配置

更新: 您现在可以简单地使用ButterKnife 9-rc02代替上述解决方案:

...
dependencies {
    implementation 'com.jakewharton:butterknife:9.0.0-SNAPSHOT'
    annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-SNAPSHOT'
...
Run Code Online (Sandbox Code Playgroud)

  • 该解决方案需要在黄油刀 9 投入生产时更新。 (2认同)

Ore*_*Ore 8

请注意,Butterknife 现在已达到 10.1.0,不再需要 SNAPSHOT 版本或任何其他 Maven 库。AndroidX 迁移很有魅力。只需包括:

dependencies {
    implementation 'com.jakewharton:butterknife:10.1.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'
}
Run Code Online (Sandbox Code Playgroud)

或者,如果出于某种原因您将 Kotlin 和 butterknife 结合使用,请替换annotationProcessorkapt.

更多信息,请访问:https : //github.com/JakeWharton/butterknife


Ism*_*ail 4

首先,我要感谢@ intellij-amiya和@Nabster的宝贵贡献,因为这个答案是基于他们提供的答案.

我的Gradle设置如下

...
apply plugin: 'com.jakewharton.butterknife'
....
dependencies{
    implementation 'com.jakewharton:butterknife:9.0.0-SNAPSHOT'
    annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-SNAPSHOT'
}
...

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

buildscript {

    repositories {
        google()
        mavenCentral()
        maven {
            name 'Sonatype SNAPSHOTs'
            url 'https://oss.sonatype.org/content/repositories/snapshots/'
        }
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0-alpha09'
        classpath 'com.google.gms:google-services:4.0.1'
        classpath 'com.jakewharton:butterknife-gradle-plugin:9.0.0-SNAPSHOT'

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

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven {
            name 'Sonatype SNAPSHOTs'
            url 'https://oss.sonatype.org/content/repositories/snapshots/'
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)