繁体   English   中英

下载最新的Gradle版本后无法建立专案

[英]Project fails to build after downloading latest gradle version

自从更新以来,我在构建时一直收到以下错误。 我尝试清理并构建,但错误仍然存​​在:

这是我尝试构建时遇到的错误:

错误:程序类型已存在: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

好的,我知道了问题所在。 在更新到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,清理并构建了项目,问题得到解决。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM