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
From @shenmingxuanyi on August 10, 2016 6:29
please update the new version to npm server
From @jpagand on August 10, 2016 7:45
Updated node to v6.3.1 Still the same error
Worked for me:
changed buildToolsVersion cdvBuildToolsVersion to buildToolsVersion "23.0.2"
@jpagand thanks this worked for me!
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
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.
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?
@rabbounicha did you resolve this issue? I am getting this now as well.
@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.
Thank you @dwieeb!, deleting platform and plugins directory worked for me.
@dwieeb @ccontreras Same for me. Thanks guys 👍
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'
}
I removed the android-support-v4.jar which located in platform/android/ . And 'ionic run android' worked successfully.
"cordova clean" fixed the issue for me.
@andrezap thanks! worked really good!
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
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).
@Migg81 Same error here, did you find a fix?
In my case issue is with plugin so I uninstall all of them and then reinstall them on by one and it got fixed.
I fixed this by adding platform to specific version: ionic cordova platform add [email protected]