Unable to make android release build

hi,
Please see the below output which occurred while I was making release of my app. However in debug mode it is successfully working and I tried to build directly from Android Studio too but, it didn’t worked out.

Please help…

Android platform version: 6.4.0
All plugins are native.
Ionic serve and ionic cordova build android are working perfectly.

PS C:\Users\RAHUL-RAJPAL\Apps\YM-Driver> ionic cordova build --release android
Running app-scripts build: --platform android --target cordova
[16:36:33] build dev started …
[16:36:34] clean started …
[16:36:34] clean finished in 108 ms
[16:36:34] copy started …
[16:36:34] deeplinks started …
[16:36:34] deeplinks finished in 118 ms
[16:36:34] transpile started …
[16:37:13] transpile finished in 38.51 s
[16:37:13] preprocess started …
[16:37:13] preprocess finished in 2 ms
[16:37:13] webpack started …
[16:37:15] copy finished in 41.18 s
[16:37:29] webpack finished in 16.32 s
[16:37:29] sass started …
Without from option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to undefined to prevent this warning.
[16:37:40] sass finished in 10.97 s
[16:37:40] postprocess started …
[16:37:40] postprocess finished in 407 ms
[16:37:40] lint started …
[16:37:44] build dev finished in 71.81 s

cordova build android --release
[16:37:50] tslint: C:/Users/RAHUL-RAJPAL/Apps/YM-Driver/src/pages/tabs/tabs.ts, line: 9
All imports are unused.

   L8:  import { Toast } from '@ionic-native/toast';
   L9:  import { AuthProvider } from '../../providers/auth/auth';
  L10:  import { LocationTrackerProvider } from '../../providers/location-tracker/location-tracker';

[16:37:50] tslint: C:/Users/RAHUL-RAJPAL/Apps/YM-Driver/src/app/app.module.ts, line: 7
All imports are unused.

   L6:  //Angular
   L7:  import { Location } from '@angular/common';
   L8:  import { HttpModule } from '@angular/http';

[16:37:50] lint finished in 9.84 s
ANDROID_HOME=C:\Users\RAHUL-RAJPAL\AppData\Local\Android\sdk
JAVA_HOME=C:\Program Files\java\jdk1.8.0_161
Subproject Path: CordovaLib
Starting a Gradle Daemon, 1 busy and 1 incompatible and 1 stopped Daemons could not be reused, use --status for details

Configuration ‘compile’ in project ‘:’ is deprecated. Use ‘implementation’ instead.
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.

    at build_d9nc495zcayzo3nzcm0o6ugs4.run(C:\Users\RAHUL-RAJPAL\Apps\YM-Driver\platforms\android\build.gradle:142)

publishNonDefault is deprecated and has no effect anymore. All variants are now published.

:preBuild
UP-TO-DATE
:CordovaLib:preBuild
UP-TO-DATE
:CordovaLib:preReleaseBuild UP-TO-DATE
:CordovaLib:checkReleaseManifest

UP-TO-DATE
:CordovaLib:processReleaseManifest

UP-TO-DATE
:preReleaseBuild

UP-TO-DATE
:CordovaLib:compileReleaseAidl

UP-TO-DATE
:compileReleaseAidl

UP-TO-DATE
:CordovaLib:packageReleaseRenderscript

NO-SOURCE
:compileReleaseRenderscript
UP-TO-DATE
:checkReleaseManifest
UP-TO-DATE
:generateReleaseBuildConfig

UP-TO-DATE
:prepareLintJar

UP-TO-DATE
:generateReleaseResValues
UP-TO-DATE
:generateReleaseResources UP-TO-DATE
:CordovaLib:compileReleaseRenderscript

UP-TO-DATE
:CordovaLib:generateReleaseResValues
UP-TO-DATE
:CordovaLib:generateReleaseResources
UP-TO-DATE
:CordovaLib:packageReleaseResources

UP-TO-DATE
:mergeReleaseResources
UP-TO-DATE
:createReleaseCompatibleScreenManifests
UP-TO-DATE
:processReleaseManifest

UP-TO-DATE
:splitsDiscoveryTaskRelease

UP-TO-DATE
:CordovaLib:platformAttrExtractor

UP-TO-DATE
:CordovaLib:processReleaseResources

UP-TO-DATE
:processReleaseResources
UP-TO-DATE
:generateReleaseSources UP-TO-DATE
:CordovaLib:generateReleaseBuildConfig
UP-TO-DATE
:CordovaLib:prepareLintJar
UP-TO-DATE
:CordovaLib:generateReleaseSources UP-TO-DATE
:CordovaLib:javaPreCompileRelease
UP-TO-DATE
:CordovaLib:compileReleaseJavaWithJavac

UP-TO-DATE
:CordovaLib:processReleaseJavaRes

NO-SOURCE
:CordovaLib:transformClassesAndResourcesWithPrepareIntermediateJarsForRelease
UP-TO-DATE
:javaPreCompileRelease

UP-TO-DATE
:compileReleaseJavaWithJavac

UP-TO-DATE
:compileReleaseNdk
NO-SOURCE
:compileReleaseSources UP-TO-DATE
:mergeReleaseShaders UP-TO-DATE
:compileReleaseShaders
UP-TO-DATE

:generateReleaseAssets UP-TO-DATE
:CordovaLib:mergeReleaseShaders

UP-TO-DATE
:CordovaLib:compileReleaseShaders UP-TO-DATE
:CordovaLib:generateReleaseAssets UP-TO-DATE
:CordovaLib:mergeReleaseAssets UP-TO-DATE
:mergeReleaseAssets

:transformClassesWithPreDexForRelease
trouble processing “javax/xml/namespace/QName.class”:

Ill-advised or mistaken usage of a core class (java.* or javax.*)
when not building a core library.
This is often due to inadvertently including a core library file
in your application’s project, when using an IDE (such as
Eclipse). If you are sure you’re not intentionally defining a
core class, then this is the most likely explanation of what’s
going on.
However, you might actually be trying to define a class in a core
namespace, the source of which you may have taken, for example,
from a non-Android virtual machine project. This will most
assuredly not work. At a minimum, it jeopardizes the
compatibility of your app with future versions of the platform.
It is also often of questionable legality.
If you really intend to build a core library – which is only
appropriate as part of creating a full virtual machine
distribution, as opposed to compiling an application – then use
the “–core-library” option to suppress this error message.
If you go ahead and use “–core-library” but are in fact
building an application, then be forewarned that your application
will still fail to build or run, at some point. Please be
prepared for angry customers who find, for example, that your
application ceases to function once they upgrade their operating
system. You will be to blame for this problem.
If you are legitimately using some code that happens to be in a
core package, then the easiest safe alternative you have is to
repackage that code. That is, move the classes in question into
your own package namespace. This means that they will never be in
conflict with core system classes. JarJar is a tool that may help
you in this endeavor. If you find that you cannot do this, then
that is an indication that the path you are on will ultimately
lead to pain, suffering, grief, and lamentation.
1 error; aborting
trouble processing “javax/xml/parsers/DocumentBuilder.class”:

Ill-advised or mistaken usage of a core class (java.* or javax.*)
when not building a core library.
This is often due to inadvertently including a core library file
in your application’s project, when using an IDE (such as
Eclipse). If you are sure you’re not intentionally defining a
core class, then this is the most likely explanation of what’s
going on.
However, you might actually be trying to define a class in a core
namespace, the source of which you may have taken, for example,
from a non-Android virtual machine project. This will most
assuredly not work. At a minimum, it jeopardizes the
compatibility of your app with future versions of the platform.
It is also often of questionable legality.
If you really intend to build a core library – which is only
appropriate as part of creating a full virtual machine
distribution, as opposed to compiling an application – then use
the “–core-library” option to suppress this error message.
If you go ahead and use “–core-library” but are in fact
building an application, then be forewarned that your application
will still fail to build or run, at some point. Please be
prepared for angry customers who find, for example, that your
application ceases to function once they upgrade their operating
system. You will be to blame for this problem.
If you are legitimately using some code that happens to be in a
core package, then the easiest safe alternative you have is to
repackage that code. That is, move the classes in question into
your own package namespace. This means that they will never be in
conflict with core system classes. JarJar is a tool that may help
you in this endeavor. If you find that you cannot do this, then
that is an indication that the path you are on will ultimately
lead to pain, suffering, grief, and lamentation.
1 error; aborting
FAILED

34 actionable tasks: 2 executed, 32 up-to-date
FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:transformClassesWithPreDexForRelease’.

com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: Unable to pre-dex ‘C:\Users\RAHUL-RAJPAL.gradle\caches\modules-2\files-2.1\xerces\xmlParserAPIs\2.6.2\65acede1e5305bd2b92213d7b5761328c6f4fd9\xmlParserAPIs-2.6.2.jar’ to ‘C:\Users\RAHUL-RAJPAL\Apps\YM-Driver\platforms\android\build\intermediates\transforms\preDex\release\28.jar’

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

  • Get more help at https://help.gradle.org

BUILD FAILED in 1m 19s
(node:8244) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: cmd: Command failed with exit code 1
Error output:
trouble processing “javax/xml/namespace/QName.class”:
Ill-advised or mistaken usage of a core class (java.* or javax.)
when not building a core library.
This is often due to inadvertently including a core library file
in your application’s project, when using an IDE (such as
Eclipse). If you are sure you’re not intentionally defining a
core class, then this is the most likely explanation of what’s
going on.
However, you might actually be trying to define a class in a core
namespace, the source of which you may have taken, for example,
from a non-Android virtual machine project. This will most
assuredly not work. At a minimum, it jeopardizes the
compatibility of your app with future versions of the platform.
It is also often of questionable legality.
If you really intend to build a core library – which is only
appropriate as part of creating a full virtual machine
distribution, as opposed to compiling an application – then use
the “–core-library” option to suppress this error message.
If you go ahead and use “–core-library” but are in fact
building an application, then be forewarned that your application
will still fail to build or run, at some point. Please be
prepared for angry customers who find, for example, that your
application ceases to function once they upgrade their operating
system. You will be to blame for this problem.
If you are legitimately using some code that happens to be in a
core package, then the easiest safe alternative you have is to
repackage that code. That is, move the classes in question into
your own package namespace. This means that they will never be in
conflict with core system classes. JarJar is a tool that may help
you in this endeavor. If you find that you cannot do this, then
that is an indication that the path you are on will ultimately
lead to pain, suffering, grief, and lamentation.
1 error; aborting
trouble processing “javax/xml/parsers/DocumentBuilder.class”:
Ill-advised or mistaken usage of a core class (java.
or javax.*)
when not building a core library.
This is often due to inadvertently including a core library file
in your application’s project, when using an IDE (such as
Eclipse). If you are sure you’re not intentionally defining a
core class, then this is the most likely explanation of what’s
going on.
However, you might actually be trying to define a class in a core
namespace, the source of which you may have taken, for example,
from a non-Android virtual machine project. This will most
assuredly not work. At a minimum, it jeopardizes the
compatibility of your app with future versions of the platform.
It is also often of questionable legality.
If you really intend to build a core library – which is only
appropriate as part of creating a full virtual machine
distribution, as opposed to compiling an application – then use
the “–core-library” option to suppress this error message.
If you go ahead and use “–core-library” but are in fact
building an application, then be forewarned that your application
will still fail to build or run, at some point. Please be
prepared for angry customers who find, for example, that your
application ceases to function once they upgrade their operating
system. You will be to blame for this problem.
If you are legitimately using some code that happens to be in a
core package, then the easiest safe alternative you have is to
repackage that code. That is, move the classes in question into
your own package namespace. This means that they will never be in
conflict with core system classes. JarJar is a tool that may help
you in this endeavor. If you find that you cannot do this, then
that is an indication that the path you are on will ultimately
lead to pain, suffering, grief, and lamentation.
1 error; aborting

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ‘:transformClassesWithPreDexForRelease’.

com.android.build.api.transform.TransformException: java.lang.RuntimeException: java.lang.RuntimeException: Unable to pre-dex ‘C:\Users\RAHUL-RAJPAL.gradle\caches\modules-2\files-2.1\xerces\xmlParserAPIs\2.6.2\65acede1e5305bd2b92213d7b5761328c6f4fd9\xmlParserAPIs-2.6.2.jar’ to ‘C:\Users\RAHUL-RAJPAL\Apps\YM-Driver\platforms\android\build\intermediates\transforms\preDex\release\28.jar’

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

  • Get more help at https://help.gradle.org

BUILD FAILED in 1m 19s
(node:8244) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Firstly, This is issue always comes when your gradle is busy.
Try ionic cordova build android 2-3 more time otherwise restart your system and perform the same command again. Make sure your command tool is in Administrator Mode.

Hi sorry for replying late, I tried but it’s not working.

I had the same problem, I just delete the android platform and then I add another platform and it works

I also have this error. Build is working when not in prod mode but error when building prod. I’ve tried cordova clean android but still error persist.