繁体   English   中英

错误:任务':app:transformClassesWithPreDexForRelease'的执行失败。 > com.android.build.api.transform.TransformException

[英]Error:Execution failed for task ':app:transformClassesWithPreDexForRelease'. > com.android.build.api.transform.TransformException

我尝试使用Generate Signed APK构建APK。 但是我有一些错误。

Error:Uncaught translation error: java.lang.IllegalArgumentException: already added: Lorg/apache/xmlbeans/xml/stream/XMLName;
Error:Uncaught translation error: java.lang.IllegalArgumentException: already added: Lorg/apache/xmlbeans/xml/stream/XMLStreamException;
Error:Uncaught translation error: java.lang.IllegalArgumentException: already added: Lorg/apache/xmlbeans/xml/stream/utils/NestedThrowable;
Error:Uncaught translation error: java.lang.IllegalArgumentException: already added: Lorg/apache/xmlbeans/xml/stream/utils/NestedThrowable$Util;
Error:8 errors; aborting
Error:Execution failed for task ':app:transformClassesWithPreDexForRelease'.
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: Unable to pre-dex 'C:\Users\AndroidStudioProjects\A\app\libs\xmlbeans-2.6.0.jar' to 'C:\Users\AndroidStudioProjects\A\app\build\intermediates\transforms\preDex\release\8'

这是我的Gradle文件。 而且我不知道这是什么问题。因为它运作良好。 只是我在制作APK时遇到问题。

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.android.A"
        multiDexEnabled true
        minSdkVersion 24
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            lintOptions{
                checkReleaseBuilds false
                abortOnError false
            }
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testImplementation 'junit:junit:4.12'

    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation 'com.google.android.gms:play-services-ads:10.0.1'
    compile('org.apache.tika:tika-parsers:1.14'){
        exclude group: 'org.apache.xmlbeans'
    }
    compile 'com.google.firebase:firebase-core:10.0.1'
    compile 'com.google.firebase:firebase-messaging:10.0.1'
    compile files('libs/curvesapi-1.04.jar')
    compile files('libs/poi-3.17.jar')
    compile files('libs/poi-examples-3.17.jar')
    compile files('libs/poi-excelant-3.17.jar')
    compile files('libs/poi-ooxml-3.17.jar')
    compile files('libs/poi-scratchpad-3.17.jar')
    compile files('libs/xmlbeans-2.6.0.jar')
    compile files('libs/poi-ooxml-schemas-3.17.jar')
}

apply plugin: 'com.google.gms.google-services'

我该如何解决? 请帮帮我。

在您的android studio中设置默认的嵌入式JDK,如下所示,然后使用干净的构建重试。

选择文件->项目结构->使用嵌入式JDK(推荐)

如果仍不能解决问题,请增加堆大小,然后重试

这可能是因为您两次将库包含在libs目录中。 首先搭配:

compile fileTree(include: ['*.jar'], dir: 'libs')

第二个:

compile files('libs/curvesapi-1.04.jar')
compile files('libs/poi-3.17.jar')
compile files('libs/poi-examples-3.17.jar')
compile files('libs/poi-excelant-3.17.jar')
compile files('libs/poi-ooxml-3.17.jar')
compile files('libs/poi-scratchpad-3.17.jar')
compile files('libs/xmlbeans-2.6.0.jar')
compile files('libs/poi-ooxml-schemas-3.17.jar')

您只需要使用以下行就可以在您的libs目录中包含所有jar:

compile fileTree(include: ['*.jar'], dir: 'libs')

暂无
暂无

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

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