构建版本签名APK时出错:错误:处理“javax / xml / namespace / QName.class”时遇到问题

时间:2017-12-25 12:24:27

标签: android android-studio android-gradle apk android-studio-3.0

我正在尝试创建一个内置的应用程序,它调试并运行良好。但是当我尝试创建已签名的apk以供发布时,它会在Android Studio 3.0.1中给出以下错误

Error:trouble processing "javax/xml/namespace/QName.class":
Error:Ill-advised or mistaken usage of a core class (java.* or javax.*)
Error:when not building a core library.
Error:This is often due to inadvertently including a core library file
Error:in your application's project, when using an IDE (such as
Error:Eclipse). If you are sure you're not intentionally defining a
Error:core class, then this is the most likely explanation of what's
Error:going on.
Error:However, you might actually be trying to define a class in a core
Error:namespace, the source of which you may have taken, for example,
Error:from a non-Android virtual machine project. This will most
Error:assuredly not work. At a minimum, it jeopardizes the
Error:compatibility of your app with future versions of the platform.
Error:It is also often of questionable legality.
Error:If you really intend to build a core library -- which is only
Error:appropriate as part of creating a full virtual machine
Error:distribution, as opposed to compiling an application -- then use
Error:the "--core-library" option to suppress this error message.
Error:If you go ahead and use "--core-library" but are in fact
Error:building an application, then be forewarned that your application
Error:will still fail to build or run, at some point. Please be
Error:prepared for angry customers who find, for example, that your
Error:application ceases to function once they upgrade their operating
Error:system. You will be to blame for this problem.
Error:If you are legitimately using some code that happens to be in a
Error:core package, then the easiest safe alternative you have is to
Error:repackage that code. That is, move the classes in question into
Error:your own package namespace. This means that they will never be in
Error:conflict with core system classes. JarJar is a tool that may help
Error:you in this endeavor. If you find that you cannot do this, then
Error:that is an indication that the path you are on will ultimately
Error:lead to pain, suffering, grief, and lamentation.
Error:1 error; aborting
Error:Execution failed for task ':app:transformClassesWithDexForRelease'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Error while executing java process with main class com.android.dx.command.Main with arguments {--dex --num-threads=4 --multi-dex --main-dex-list D:\Android\Projects\Online Food Order\CommonApp\app\build\intermediates\multi-dex\release\maindexlist.txt --output D:\Android\Projects\Online Food Order\CommonApp\app\build\intermediates\transforms\dex\release\0 --min-sdk-version 17 D:\Android\Projects\Online Food Order\CommonApp\app\build\intermediates\transforms\jarMerging\release\0.jar}
Information:BUILD FAILED in 1m 28s
Information:34 errors
Information:0 warnings

我试图找出所有内容,但无法获得解决此问题的解决方案。任何人都可以帮助我克服它。

以下是我的Gradle文件。

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'


repositories {
    maven { url 'https://maven.fabric.io/public' }
    maven { url 'https://maven.google.com' }
}

android {

    compileSdkVersion 27
    buildToolsVersion "26.0.2"
    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        applicationId "<My Project Id>"
        minSdkVersion 17
        targetSdkVersion 27
        versionCode 1
        versionName "1.0.0"
        multiDexEnabled true
        manifestPlaceholders = [onesignal_app_id: "<My Onesignal App Id",
                                // Project number pulled from dashboard, local value is ignored.
                                onesignal_google_project_number: "REMOTE"]

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    dexOptions {
        javaMaxHeapSize "4g"
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
    }

    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }

}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:27.0.2'
    compile 'com.android.support:multidex:1.0.1'
    compile('com.crashlytics.sdk.android:crashlytics:2.6.7@aar') {
        transitive = true;
    }
    compile 'com.google.android.gms:play-services:11.6.2'
    compile('com.twitter.sdk.android:twitter:1.12.1@aar') {
        transitive = true;
        exclude module: 'gson';
    }
    compile 'com.android.support:design:27.0.2'
    compile 'com.android.support:support-v13:+'
    compile 'com.paypal.sdk:paypal-android-sdk:2.13.1'
    compile 'com.android.support:support-v4:27.0.2'
    compile 'com.baoyz.swipemenulistview:library:1.3.0'
    compile 'com.braintreepayments.api:drop-in:3.+'
    compile 'com.lukekorth:mailable_log:0.1.4'
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.google.code.gson:gson:2.6.2'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
    compile 'com.squareup.okhttp3:okhttp:3.4.1'
    compile 'com.google.firebase:firebase-core:11.6.2'
    compile 'com.google.firebase:firebase-messaging:11.6.2'
    compile 'com.facebook.android:facebook-login:4.27.0'
    compile 'com.onesignal:OneSignal:[3.6.2, 3.99.99]'
    compile 'net.authorize:accept-sdk-android:1.0.2'
    compile 'com.jakewharton:butterknife:8.5.1'
}

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '26.0.2'
            }
        }
    }
}

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

我也见过this,但这无法帮我解决问题。

任何帮助将不胜感激。在此先感谢。

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题。经过几个小时的谷歌搜索,我找到了Amira Elsayed Ismail对gdbm帖子的评论的解决方法。

解决方案:

我已将gradle还原到项目级别build.gradle文件

中的早期版本

已更改

classpath 'com.android.tools.build:gradle:3.0.0'  

classpath 'com.android.tools.build:gradle:2.3.3' 

现在,它运作正常。