自更新以来,我在构建时总是收到以下错误。我尝试清理并构建,但错误仍然存在:
这是我尝试构建时遇到的错误:
错误:程序类型已存在:org.apache.xmlbeans.xml.stream.Location
该问题似乎与xmlbeans-2.6.0.jar的问题有关,但是我并不真正了解“ dexingTransform”试图做什么。更新后,我需要添加任何东西来支持我的项目吗?
这是我的build.grade:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "app.testApp"
minSdkVersion 26
targetSdkVersion 28
versionCode 1
versionName "1.0"
multiDexEnabled true
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:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:multidex:1.0.3'
implementation "org.apache.poi:poi:3.17"
implementation "org.apache.poi:poi-ooxml:3.17"
implementation 'com.fasterxml:aalto-xml:1.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.jakewharton:butterknife:8.5.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
以及以下报告的我无法理解的错误,这些错误在更新后出现:
org.gradle.initialization.ReportedException: org.gradle.internal.exceptions.LocationAwareException: Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Caused by: org.gradle.api.artifacts.transform.ArtifactTransformException: Failed to transform file 'xmlbeans-2.6.0.jar' to match attributes {artifactType=android-dex, dexing-is-debuggable=true, dexing-min-sdk=26} using transform DexingTransform
Caused by: com.android.tools.r8.utils.AbortException: Error: Program type already present: org.apache.xmlbeans.xml.stream.Location
答案 0 :(得分:0)
好的,我已经弄清楚了问题所在。在更新到gradle 4.4之后发现,如果您的项目中有重复的库引用,则会出现错误。在我的情况下,这是xmlbeans-2.6.0.jar,并且我有以下相互依赖的依赖项:
implementation "org.apache.poi:poi:3.17"
implementation "org.apache.poi:poi-ooxml:3.17"
implementation 'com.fasterxml:aalto-xml:1.0.0'
implementation 'com.jakewharton:butterknife:8.5.1'
因此,就我而言,我保留以下内容,并注释掉其余内容:
//implementation "org.apache.poi:poi:3.17"
//implementation "org.apache.poi:poi-ooxml:3.17"
//implementation 'com.fasterxml:aalto-xml:1.0.0'
implementation 'com.jakewharton:butterknife:8.5.1'
然后我重新同步了gradle,清理并构建了项目,而我的问题已解决。