我想使用AndroidX库,下面是Butterknife的Gradle设置
app:模块依赖
implementation 'com.jakewharton:butterknife:9.0.0-SNAPSHOT'
annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-SNAPSHOT'
插入
申请插件:’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
}
项目存储库
repositories {
google()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
jcenter()
}
解决方法:
更新:
您现在可以简单地使用ButterKnife 9-rc02代替上述解决方案:
...
dependencies {
implementation 'com.jakewharton:butterknife:9.0.0-rc2'
annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-rc2'
...
根据Naveen的回答,解决方案是here.
但是,缺少细节.请参阅以下Gradle配置以获取完整的解决方案:
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
}
和
...
dependencies {
implementation 'com.jakewharton:butterknife:9.0.0-SNAPSHOT'
annotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-SNAPSHOT'
...
基本上,不要使用apply plugin:’com.jakewharton.butterknife’和classpath’com.jakewharton:butterknife-gradle-plugin:9.0.0-SNAPSHOT’来自建议here.