0

I am trying to create a built of my application, it debugs and runs well. But when i try to create the signed apk for release, it gives me following error in 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

I tried to find out everything but cannot get the solution to resolve this issue. Can anyone Please help me overcome it.

Below is my Gradle File.

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'

I have also seen this but this could not help me to solve the solution.

Any help will be appreciated. Thanks in Advance.

Pravinsingh Waghela
  • 2,516
  • 4
  • 32
  • 50
  • I think you have imported a class from `javax` package by mistake. Check for imports from `javax` and validate if they are the correct package you wanted or are imported incorrectly. – Akram Dec 25 '17 at 12:28
  • @Merka How can I check imports from javax? Can you please explain more or way to do so? – Pravinsingh Waghela Dec 25 '17 at 12:31
  • @PravinsinghWaghela I meant by searching `import javax` in your whole project by `Ctrl+shift+F`. And @Hangman link may also be the cause. – Akram Dec 25 '17 at 12:32
  • @Hangman I had gone through it, but i am not having any jar in my libs folder. You could have get an idea from my gradle that i am not using any jar as library imports. – Pravinsingh Waghela Dec 25 '17 at 12:33
  • @Merka I has search both javax.* and java.* but I haven't imported either of them. So can you please suggest any other way to overcome it? – Pravinsingh Waghela Dec 28 '17 at 11:39
  • I am facing the same issue and could not release the app to the client. Can anyone help me to find the solution for this ? – Rakesh L Jan 02 '18 at 16:38
  • @RakeshL check my answer https://stackoverflow.com/a/48647473/5805371 – Yuri Popiv Feb 07 '18 at 11:32

1 Answers1

0

I have faced the same issue . After several hours of googling , I have found a workaround by the comment of Amira Elsayed Ismail to this post.

Solution:

I have reverted the gradle to earlier version in my project level build.gradle file

Changed

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

to

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

Now, it works fine.

Rakesh L
  • 1,136
  • 4
  • 18
  • 44