ionic-cli: Error build Android: Execution failed for task ':transformClassesWithDexForDebug'.

From @jpagand on August 10, 2016 6:5

Just trying to build on android the ionic 2 boilerplate app

Here is the build log:

$ ionic build android --info

Running 'build:before' gulp task before build
[07:58:52] Starting 'clean'...
[07:58:52] Finished 'clean' after 36 ms
[07:58:52] Starting 'build'...
[07:58:52] Starting 'sass'...
[07:58:52] Starting 'html'...
[07:58:52] Starting 'fonts'...
[07:58:52] Starting 'scripts'...
[07:58:52] Finished 'html' after 58 ms
[07:58:52] Finished 'scripts' after 87 ms
[07:58:52] Finished 'fonts' after 98 ms
[07:58:53] Finished 'sass' after 941 ms
[07:59:02] Finished 'build' after 10 s
[07:59:02] Starting 'build:before'...
[07:59:02] Finished 'build:before' after 9.47 μs

Running command: "c:\Program Files\nodejs\node.exe" c:\Users\***\ionic2
\hooks\after_prepare\010_add_platform_class.js c:/Users/***/ionic2


add to body class: platform-android

ANDROID_HOME=C:\Users\***\AppData\Local\Android\sdk

JAVA_HOME=C:\Program Files\Java\jdk1.7.0_21

Incremental java compilation is an incubating feature.


:preBuild
 UP-TO-DATE
:preDebugBuild UP-TO-DATE

:checkDebugManifest

:CordovaLib:preBuild
 UP-TO-DATE


:CordovaLib:preDebugBuild
 UP-TO-DATE
:CordovaLib:compileDebugNdk
UP-TO-DATE
:CordovaLib:compileLint

:CordovaLib:copyDebugLint
 UP-TO-DATE
:CordovaLib:mergeDebugProguardFiles
 UP-TO-DATE

:CordovaLib:packageDebugRenderscript
 UP-TO-DATE

:CordovaLib:checkDebugManifest


:CordovaLib:prepareDebugDependencies


:CordovaLib:compileDebugRenderscript
 UP-TO-DATE

:CordovaLib:generateDebugResValues
 UP-TO-DATE


:CordovaLib:generateDebugResources UP-TO-DATE

:CordovaLib:packageDebugResources
 UP-TO-DATE

:CordovaLib:compileDebugAidl

UP-TO-DATE
:CordovaLib:generateDebugBuildConfig
 UP-TO-DATE

:CordovaLib:mergeDebugShaders
 UP-TO-DATE

:CordovaLib:compileDebugShaders
 UP-TO-DATE

:CordovaLib:generateDebugAssets

UP-TO-DATE

:CordovaLib:mergeDebugAssets
 UP-TO-DATE

:CordovaLib:processDebugManifest
 UP-TO-DATE


:CordovaLib:processDebugResources
 UP-TO-DATE
:CordovaLib:generateDebugSources UP-TO-DATE
:CordovaLib:incrementalDebugJavaCompilationSafeguard

UP-TO-DATE
:CordovaLib:compileDebugJavaWithJavac

UP-TO-DATE
:CordovaLib:processDebugJavaRes
 UP-TO-DATE

:CordovaLib:transformResourcesWithMergeJavaResForDebug
 UP-TO-DATE

:CordovaLib:transformClassesAndResourcesWithSyncLibJarsForDebug
 UP-TO-DATE

:CordovaLib:mergeDebugJniLibFolders
 UP-TO-DATE

:CordovaLib:transformNative_libsWithMergeJniLibsForDebug
 UP-TO-DATE

:CordovaLib:transformNative_libsWithSyncJniLibsForDebug
 UP-TO-DATE

:CordovaLib:bundleDebug

UP-TO-DATE

:prepareAndroidCordovaLibUnspecifiedDebugLibrary
 UP-TO-DATE

:preReleaseBuild
UP-TO-DATE
:CordovaLib:preReleaseBuild
 UP-TO-DATE

:CordovaLib:compileReleaseNdk
 UP-TO-DATE


:CordovaLib:copyReleaseLint
 UP-TO-DATE

:CordovaLib:mergeReleaseProguardFiles


:CordovaLib:packageReleaseRenderscript

UP-TO-DATE
:CordovaLib:checkReleaseManifest


:CordovaLib:prepareReleaseDependencies


:CordovaLib:compileReleaseRenderscript

:CordovaLib:generateReleaseResValues


:CordovaLib:generateReleaseResources
:CordovaLib:packageReleaseResources


:CordovaLib:compileReleaseAidl


:CordovaLib:generateReleaseBuildConfig


:CordovaLib:mergeReleaseShaders


:CordovaLib:compileReleaseShaders


:CordovaLib:generateReleaseAssets
:CordovaLib:mergeReleaseAssets


:CordovaLib:processReleaseManifest


:CordovaLib:processReleaseResources


:CordovaLib:generateReleaseSources
:CordovaLib:incrementalReleaseJavaCompilationSafeguard


:CordovaLib:compileReleaseJavaWithJavac


:CordovaLib:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have
changed, no previous execution, etc.).

Note: Some input files use or override a deprecated API.

Note: Recompile with -Xlint:deprecation for details.

:CordovaLib:processReleaseJavaRes

UP-TO-DATE
:CordovaLib:transformResourcesWithMergeJavaResForRelease


:CordovaLib:transformClassesAndResourcesWithSyncLibJarsForRelease


:CordovaLib:mergeReleaseJniLibFolders


:CordovaLib:transformNative_libsWithMergeJniLibsForRelease


:CordovaLib:transformNative_libsWithSyncJniLibsForRelease


:CordovaLib:bundleRelease


:prepareComAndroidSupportMultidex101Library


:prepareDebugDependencies


:compileDebugAidl
 UP-TO-DATE

:compileDebugRenderscript
 UP-TO-DATE

:generateDebugBuildConfig

UP-TO-DATE
:mergeDebugShaders
 UP-TO-DATE

:compileDebugShaders
 UP-TO-DATE

:generateDebugAssets
 UP-TO-DATE

:mergeDebugAssets
 UP-TO-DATE

:generateDebugResValues
 UP-TO-DATE
:generateDebugResources UP-TO-DATE

:mergeDebugResources
 UP-TO-DATE

:processDebugManifest


:processDebugResources

UP-TO-DATE
:generateDebugSources UP-TO-DATE

:incrementalDebugJavaCompilationSafeguard
 UP-TO-DATE

:compileDebugJavaWithJavac

None of the classes needs to be compiled! Analysis took 0.004 secs.


:compileDebugNdk
 UP-TO-DATE

:compileDebugSources


:prePackageMarkerForDebug


:transformClassesWithJarMergingForDebug


:collectDebugMultiDexComponents


:transformClassesWithMultidexlistForDebug

ProGuard, version 5.2.1


Reading program jar [C:\Users\***\ionic2\platforms\android\build\inter
mediates\transforms\jarMerging\debug\jars\1\1f\combined.jar]

Reading library jar [C:\Users\***\AppData\Local\Android\sdk\build-tools\24.0
.1\lib\shrinkedAndroid.jar]


Preparing output jar [C:\Users\***\ionic2\platforms\android\build\inte
rmediates\multi-dex\debug\componentClasses.jar]

  Copying resources from program jar [C:\Users\***\ionic2\platforms\an
droid\build\intermediates\transforms\jarMerging\debug\jars\1\1f\combined.jar]

:transformClassesWithMultidexlistForDebug
FAILED



FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':transformClassesWithMultidexlistForDebug'.

> com.android.build.api.transform.TransformException: com.android.ide.common.pro
cess.ProcessException: org.gradle.process.internal.ExecException: Process 'comma
nd 'C:\Program Files\Java\jdk1.7.0_21\bin\java.exe'' finished with non-zero exit
 value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug

BUILD FAILED

Total time: 2.937 secs

 option to get more log output.

Error: cmd: Command failed with exit code 1 Error output:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':transformClassesWithMultidexlistForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.pro
cess.ProcessException: org.gradle.process.internal.ExecException: Process 'comma
nd 'C:\Program Files\Java\jdk1.7.0_21\bin\java.exe'' finished with non-zero exit
 value 1

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

I tried to add

defaultConfig {     
  multiDexEnabled true
}

and

dexOptions {
  incremental = true;
  preDexLibraries = false
  javaMaxHeapSize "2g" 
}

But the same error persists

ionic info:

Cordova CLI: 6.3.0
Gulp version:  CLI version 3.9.1
Gulp local:   Local version 3.9.1
Ionic Framework Version: 2.0.0-beta.11
Ionic CLI Version: 2.0.0-beta.36
Ionic App Lib Version: 2.0.0-beta.19
OS: Windows 7 SP1
Node Version: v0.12.15

Copied from original issue: driftyco/ionic#7634

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 31 (3 by maintainers)

Most upvoted comments

“cordova clean” fixed the issue for me.

@rabbounicha @Ross-Rawlins I’m going to close this issue, as it actually doesn’t relate to the Ionic CLI. My suggestion would be to try removing the platforms and plugins directories (if you haven’t made any modifications inside them) and re-running the command. Sometimes Cordova projects gets corrupted. If that doesn’t work, then two or more of your plugins are fighting over something. You can get more help in the Ionic forums or stack overflow.

Hi, what fixed it for me was: ionic platform remove android and ionic platform add android

That was after I:

  • gulp-sass -> version to 2.0.0 or higher in packages.json and then npm install --save-dev gulp-sass
  • downgraded and upgraded cordova
  • downgraded node from 6.9.1 to 4.6.2

I had all the issues because of many changes in an old stack. Needless to say the dependency hell in npm s terrible and it is best to stick to the stable versions.

By the way, bot before and after adding the platform I had buildToolsVersion cdvBuildToolsVersion in some gradle build files, it did not change.

I fixed this by adding platform to specific version: ionic cordova platform add android@6.2.3

Worked for me: changed buildToolsVersion cdvBuildToolsVersion to buildToolsVersion "23.0.2"

Actually worked for me.

Ionic cordova platform remove android ionic cordova platform add android

And if the problem continues:

-cmd with administrator rights -npm install

and after that, you’ll be able to build your apk for your device.

Here another solution from the ionic framework forum

@andrezap thanks! worked really good!

Try install cordova-android-play-services-gradle-release Another way : in \platforms\android\project.properties, replace PLAY_SERVICES_VERSION by “+” only com.google.android.gms:play-services-base:+ com.google.android.gms:play-services-ads:+

Thank you @dwieeb!, deleting platform and plugins directory worked for me.