我正在尝试构建Instant App,但基本功能模块出现错误:
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和`butterknife:9.0.0-rc2',这是支持androidX的最新版本。
这个问题似乎是黄油刀的一种依赖,无法被消除
我无法禁用Jetifier,因为我正在使用androidX和SDK 28
欢迎任何帮助。我还在Butterknife项目中提出了一个问题:
答案 0 :(得分:1)
将您的Gradle设置与JakeWharton/butterknife ...上的说明进行比较...
您似乎无意中(?)添加了一个可能导致此问题的依赖项:
基本/依赖项
implementation "com.jakewharton:butterknife-gradle-plugin:${butterknifeVersion}"
该名称只能位于 root / buildscript / dependencies 中,因此请将其删除并重试。否则,其他一切看起来都很好。
我相信Jake也暗示了@ JakeWharton/butterknife/issues/1414#issuecomment-443880715
应该将Gradle插件添加到buildscript类路径中,而不是 应用的实现配置。请参阅自述文件 复制/粘贴示例。