Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error build Android: Execution failed for task ':transformClassesWithDexForDebug'. #1256

Closed
jgw96 opened this issue Aug 10, 2016 · 31 comments
Closed

Comments

@jgw96
Copy link
Contributor

jgw96 commented Aug 10, 2016

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: ionic-team/ionic-framework#7634

@jgw96
Copy link
Contributor Author

jgw96 commented Aug 10, 2016

From @shenmingxuanyi on August 10, 2016 6:29

please update the new version to npm server

@jgw96
Copy link
Contributor Author

jgw96 commented Aug 10, 2016

From @jpagand on August 10, 2016 7:45

Updated node to v6.3.1
Still the same error

@jpagand
Copy link

jpagand commented Aug 17, 2016

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

@AcademyLime
Copy link

@jpagand thanks this worked for me!

@jaswinderwadali
Copy link

jaswinderwadali commented Oct 21, 2016

Any buddy solve this problem
even i have added all manually buildToolsVersion ,
minSdkVersion 16
targetSdkVersion 23
multiDexEnabled true
and javaheap size
change java version also with java 7 but it still showing error

@VGerris
Copy link

VGerris commented Nov 22, 2016

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.

@rabbounicha
Copy link

rabbounicha commented Apr 16, 2017

Hello,

When i run "ionic run android --device", it shows this error message.

:transformClassesWithDexForDebug FAILED

BUILD FAILED

Total time: 32.749 secs

FAILURE: Build failed with an exception.

What went wrong: Execution failed for task ':transformClassesWithDexForDebug'.

    com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/common/api/zza;

And, this is my platforms/android/project.proporties details :

//Project target.
target=android-24
android.library.reference.1=CordovaLib
cordova.system.library.1=com.google.firebase:firebase-core:+
cordova.system.library.2=com.google.firebase:firebase-messaging:+
cordova.gradle.include.1=cordova-plugin-fcm/logipaxV2-FCMPlugin.gradle
cordova.gradle.include.2=cordova-plugin-mauron85-background-geolocation/logipaxV2-logtofile.gradle
cordova.system.library.3=com.google.android.gms:play-services-location:9.0.0
cordova.system.library.4=com.android.support:support-v4:+

Does anyone know how to fix this problem?

@Ross-Rawlins
Copy link

@rabbounicha did you resolve this issue? I am getting this now as well.

@imhoffd
Copy link
Contributor

imhoffd commented Jun 13, 2017

@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.

@imhoffd imhoffd closed this as completed Jun 13, 2017
@ccontreras
Copy link

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

@mtrl
Copy link

mtrl commented Jun 28, 2017

@dwieeb @ccontreras Same for me. Thanks guys 👍

@jvaranam
Copy link

jvaranam commented Aug 4, 2017

The issue resolved on 3.7 by adding the below code on platforms/android/build.gradle

configurations { all*.exclude group: 'com.android.support', module: 'support-v4' }

Complete line of codes
android { sourceSets { main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] resources.srcDirs = ['src'] aidl.srcDirs = ['src'] renderscript.srcDirs = ['src'] res.srcDirs = ['res'] assets.srcDirs = ['assets'] jniLibs.srcDirs = ['libs'] } } configurations { all*.exclude group: 'com.android.support', module: 'support-v4' }

@hix41
Copy link

hix41 commented Sep 26, 2017

I removed the android-support-v4.jar which located in platform/android/ .
And 'ionic run android' worked successfully.

@andrezap
Copy link

andrezap commented Oct 3, 2017

"cordova clean" fixed the issue for me.

@gabolucuy
Copy link

@andrezap thanks! worked really good!

@slclark
Copy link

slclark commented Oct 20, 2017

I had to uninstall all of my plugins and reinstall with ionic cordova plugin remove/add cordova-plugin-PLUGINNAME then I could build and run again

@Migg81
Copy link

Migg81 commented Nov 1, 2017

I am facing same issue could someone please help me

:transformClassesWithDexForDebug
FAILED

BUILD FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':transformClassesWithDexForDebug'.

com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexExcepti
on: Multiple dex files define Lorg/apache/cordova/BuildHelper;

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

Total time: 8.358 secs
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.
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
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 ':transformClassesWithDexForDebug'.

com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexExcepti
on: Multiple dex files define Lorg/apache/cordova/BuildHelper;

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

[ERROR] An error occurred while running cordova run android (exit code 1).

@appimobile
Copy link

@Migg81 Same error here, did you find a fix?

@Migg81
Copy link

Migg81 commented Nov 14, 2017

In my case issue is with plugin so I uninstall all of them and then reinstall them on by one and it got fixed.

@andzejsw
Copy link

I fixed this by adding platform to specific version:
ionic cordova platform add [email protected]

@ihsanberahim
Copy link

ihsanberahim commented Jan 1, 2018

Here another solution from the ionic framework forum

@bhumin3i
Copy link


    @ionic/cli-utils  : 1.19.1
    ionic (Ionic CLI) : 3.19.1

global packages:

    cordova (Cordova CLI) : 8.0.0

local packages:

    @ionic/app-scripts : 3.1.6
    Cordova Platforms  : android 7.0.0
    Ionic Framework    : ionic-angular 3.9.2

System:

    Node : v8.9.2
    npm  : 5.5.1
    OS   : Windows 7

Environment Variables:

    ANDROID_HOME : not set

Misc:

    backend : legacy

===========================> error <==========================

:app:extractTryWithResourcesSupportJarDebug UP-TO-DATE
:app:transformClassesWithStackFramesFixerForDebug
UP-TO-DATE
:app:transformClassesWithDesugarForDebug
UP-TO-DATE
:app:transformClassesWithDexBuilderForDebug
UP-TO-DATE
:app:transformDexArchiveWithExternalLibsDexMergerForDebug
FAILED
38 actionable tasks: 4 executed, 34 up-to-date

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.

java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

  • 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 12s
(node:2632) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.

java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex

  • 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 12s
(node:2632) [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.

[OK] Your app has been deployed.
Did you know you can live-reload changes from your app with --livereload?

@TheNaderio
Copy link

@dweeb 's answere is too easy to solve this - but it works perfect!

@tonmoyUI
Copy link

try with this command once, hope it will fix your issue
cordova plugin rm cordova-plugin-compat --force
cordova platform rm android
cordova platform add android

@lokeshdaiya
Copy link

@andrezap thanks.... it worked for me without removing anything.

@dvhung95
Copy link

dvhung95 commented Mar 12, 2018

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:+

@maikosoft
Copy link

@dwieeb Thank you.

@SyedAliHassanShahBukhari

Worked for me:
make sure your npm server is up to date.

cordova platfrom remove android
cordova platfrom add android

@mbdwey
Copy link

mbdwey commented Mar 28, 2018

like @tonmoyUI said
The reason is

This plugin is no longer being worked on as the functionality provided by this plugin is now included in cordova-android 6.3.0. You should upgrade your application to use version 1.2.0 of this plugin. It will detect whether or not the plugin is required based on the version of cordova-android your app uses.

@kevinHernandez05
Copy link

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.

@JadMokdad
Copy link

This issue happened to me after opening the android directory in Android Sutdio. Apprently, a local.properties file was created, containing ndk home path. I removed the file and got it back working perfectly. Hope it helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests