【发布时间】:2018-12-02 21:49:46
【问题描述】:
我正在尝试构建一个即时应用程序,但在我的基本功能模块中出现错误:
Failed to transform 'C:\...\.gradle\caches\modules-2\files-2.1\com.android.tools.build\builder\3.1.4\...\builder-3.1.4.jar' using
Jetifier. Reason: duplicate entry: module-info.class.
我在项目级别使用以下配置:
buildscript {
ext.kotlin_version = '1.3.10'
repositories {
google()
jcenter()
mavenCentral()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.jakewharton:butterknife-gradle-plugin:9.0.0-rc2'
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven {
url 'https://maven.google.com/'
}
}
}
这是我的基本功能模块,不包括applicationId
apply plugin: 'com.android.feature'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.jakewharton.butterknife'
apply plugin: 'com.google.cloud.tools.endpoints-framework-client'
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
// V2: Add the new Endpoints Framework plugin dependencies
classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:1.0.2'
}
}
android {
compileSdkVersion 28
baseFeature true
defaultConfig {
minSdkVersion 14
targetSdkVersion 28
versionCode 2302
versionName "2.3.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
setProperty("archivesBaseName", "phone-release-$versionCode")
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
ext {
butterknifeVersion = "9.0.0-rc2"
}
dependencies {
application project(':installed')
kapt "com.jakewharton:butterknife-compiler:${butterknifeVersion}"
debugImplementation 'com.facebook.stetho:stetho:1.5.0'
endpointsServer project(path: ':api', configuration: 'endpoints')
implementation(project(':core'))
implementation 'com.annimon:stream:1.2.1'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
implementation('com.google.api-client:google-api-client:1.23.0') {
exclude module: 'httpclient'
}
implementation('com.google.api-client:google-api-client-android:1.23.0') {
exclude module: 'httpclient'
}
implementation "com.google.android.gms:play-services-maps:16.0.0"
implementation "com.google.android.gms:play-services-analytics:16.0.5"
implementation "com.google.android.gms:play-services-location:16.0.0"
implementation 'com.google.firebase:firebase-core:16.0.5'
implementation "com.google.firebase:firebase-ads-lite:17.1.1"
implementation "com.google.firebase:firebase-messaging:17.3.4"
implementation "com.google.firebase:firebase-config:16.1.0"
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.google.maps.android:android-maps-utils:0.5'
implementation "com.jakewharton:butterknife:${butterknifeVersion}"
implementation "com.jakewharton:butterknife-gradle-plugin:${butterknifeVersion}"
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation group: 'io.reactivex.rxjava2', name: 'rxjava', version: '2.2.2'
implementation group: 'io.reactivex.rxjava2', name: 'rxandroid', version: '2.0.2'
}
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android-extensions'
结果:
* What went wrong:
Execution failed for task ':base:compileDebugKotlin'.
> Could not resolve all artifacts for configuration ':base:debugCompileClasspath'.
> Failed to transform file 'builder-3.1.4.jar' to match attributes {artifactType=processed-jar} using transform JetifyTransform
> Failed to transform 'C:\...\.gradle\caches\modules-2\files-2.1\com.android.tools.build\builder\3.1.4\afbcd4b7002c61fe898b1b4c50ed9e62386125d8\
builder-3.1.4.jar' using Jetifier. Reason: duplicate entry: module-info.class. (Run with --stacktrace for more details.) To disable Jetifier, set android.enable
Jetifier=false in your gradle.properties file.
如您所见,我使用的是 androidX 和支持 androidX 的最新版本 `butterknife:9.0.0-rc2'。
问题似乎是来自无法 Jetified 的黄油刀的依赖
我无法禁用 jetifier,因为我正在使用 androidX 和 SDK 28
欢迎任何帮助。我还在 Butterknife 项目中提交了一个问题:
【问题讨论】:
-
您能添加您应用的 Gradle 插件吗? (
apply plugin声明) -
类似问题,但对于 3.4,请参阅 stackoverflow.com/questions/53329450/… 可能有些东西不适用于 3.3
-
谢谢你们。我发现您链接@TWL 的问题在Android Studio 3.2.1 中不存在。我已经用你的 cmets 更新了这个问题。该问题仍然受到 builder-3.1.4 的影响
-
好的,查看了你的文件和butterknife的设置说明,我发现一个奇怪的地方是:你为什么将
implementation "com.jakewharton:butterknife-gradle-plugin:${butterknifeVersion}"添加到你的base/dependencies中?它只要求您将其添加到 root/buildscript/dependencies -
谢谢@TWL!!我为此浪费了很多时间。我添加了不必要的依赖项。如果您将其发布为答案,我可以将其标记为已接受的答案。
标签: android butterknife android-instant-apps androidx