Ionic 3 - Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug' - android

I am having trouble in building my ionic 3 app. Every time I try to build the android app it gives the following error.
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:
37 actionable tasks: 10 executed, 27 up-to-date
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 35s
(node:5924) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): 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 unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Picked up _JAVA_OPTIONS: -Xmx512M
Picked up _JAVA_OPTIONS: -Xmx512M
Picked up _JAVA_OPTIONS: -Xmx512M
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 35s
Picked up _JAVA_OPTIONS: -Xmx512M
(node:5924) [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.
Can anyone help me with the issue?

cordova clean android should fix your problem.

I solved it by removing platform and adding it again:
ionic cordova platform rm android
ionic cordova platform rm ios
ionic cordova platform add android
ionic cordova platform add ios

If the cordova clean command does not solve this problem for you, it might be related to the new implementation of AndroidX in some of your libraries.
In my case it was cordova-plugin-firebase-analytics
Follow these steps:
0 / Remove your android platform
cordova platform rm android
1 / Remove all plugins related to support / gradle / firebase versions control (Optional -- I didn't need to remove any plugins. So if you are not sure about how to do this, just skip this step)
2 / Add the AndroidX plugins from #dpa99c :
# add plugin to enable AndroidX in the project
cordova plugin add cordova-plugin-androidx
# add plugin to patch existing plugin source that uses the Android Support Library to use AndroidX
cordova plugin add cordova-plugin-androidx-adapter
3 / Add your android platform
cordova platform add android
Thanks to #MathieuNa : https://forum.ionicframework.com/t/d8-program-type-already-present/166812/4?u=carlosglegaspi

Delete this folder: "../app/build"

Related

com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex in ionic 5

everyone, please help me. im running ionic cordova run android. then an error occured. before install plugin facebook4 things are going well, after instal the plugin im can not build or run android. i have running cordova clean and cordova build not solved my problem.
:app:transformClassesWithDesugarForDebug
:app:transformClassesWithDexBuilderForDebug
:app:transformDexArchiveWithExternalLibsDexMergerForDebug FAILED
42 actionable tasks: 40 executed, 2 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 2m 49s
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: E:\PROJECT\spectraapp\platforms\android\app\src\main\java\org\apache\cordova\file\AssetFilesystem.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
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 2m 49s
[ERROR] An error occurred while running subprocess cordova.
cordova.cmd build android --device exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
Try removing platform and re-add it.
ionic cordova platform remove android
ionic cordova platform add android
then try
ionic cordova run android
If still have some issue
check it
solved. iam remove plugin facebook and add again with version #1.7.4
ionic cordova plugin add cordova-plugin-facebook4#1.7.4 --variable APP_ID="appid" --variable APP_NAME="appname"
add resource strings.xml in platforms/android/app/src/main/res/values/strings.xml
<string name="fb_app_id">appid</string>
<string name="fb_app_name">appname</string>
ionic cordova run android

Error deploying Ionic app to Android Phone (Ionic 4)

I am running the command ionic cordova run android with the usb cable connected as expected. The app builds, and then when it starts to build the apk to deploy on to my phone I'm hit with this error in the terminal.
> cordova run android Android Studio project detected ANDROID_HOME=/Users/user/Library/Android/sdk JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home studio Subproject Path: CordovaLib Subproject Path: app publishNonDefault is deprecated and has no effect anymore. All variants are now published. 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_3e7pv4o3p5wholih0470cvjae.run(/Users/user/Documents/BoutiqueSolicitors/BoutiqueSolicitors/platforms/android/app/build.gradle:148) Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead. :CordovaLib:preBuild UP-TO-DATE :CordovaLib:preDebugBuild UP-TO-DATE :CordovaLib:compileDebugAidl FAILED
FAILURE: Build failed with an exception.
* What went wrong: null value in entry: incrementalFolder=null
* 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 4s 1 actionable task: 1 executed /Users/user/Documents/BoutiqueSolicitors/BoutiqueSolicitors/platforms/android/gradlew: Command failed with exit code 1 Error output: FAILURE: Build failed with an exception.
* What went wrong: null value in entry: incrementalFolder=null
* 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 4s [ERROR] An error occurred while running subprocess cordova.
cordova run android exited with exit code 1.
I looked up the error: incrementalFolder=null, and I found that people were saying to fix this error you need to delete .gradle folder inside the root directory of an existing android studio project. I have tried this with no change.
Does anyone know a fix for this? I am clueless, any help would be greatly appreciated.
Subproject Path: CordovaLib Subproject Path: app publishNonDefault is deprecated and has no effect anymore. All variants are now published.-----------> No impact.
The Task.leftShift(Closure) method has been deprecated and is scheduled to be removed in Gradle 5.0. Please use Task.doLast(Action) instead.----------->No impact.
at build_3e7pv4o3p5wholih0470cvjae.run (/Users/user/Documents/BoutiqueSolicitors/BoutiqueSolicitors/platforms/android/app/build.gradle:148) Configuration 'compile' in project ':app' is deprecated. Use 'implementation' instead. ---------->Modify dependencies in app/build.gradle to use 'implemntation' instead of 'compile'.
:CordovaLib:preBuild UP-TO-DATE :CordovaLib:preDebugBuild UP-TO-DATE :CordovaLib:compileDebugAidl FAILED.------------>look into your aidl related changes; like definition and location of aidl interface.
run command 'gradlew assembleDebug --debug' from android studio terminal and see if it gives more details on build failure.

Ionic Cordova run failure for "ionic cordova run android"

I have an Ionic Cordova app that I have not touched in a few months. I wanted to make a small tweak to the app today and release it but when I did, I started having a dependency issue.
When I try to run 'ionic cordova run android' the build fails. Even without making any changes to the app (revert all changes and try to build what worked for the last APK) it still is failing. I have tried uninstalling the cordova intercom plugin and that changed nothing. I have also tried updating all of my npm packages and that did not help either.
This is the error log I get:
cordova run android
Android Studio project detected
cordova-android-firebase-gradle-release: Android platform: cordova-android#7
cordova-android-firebase-gradle-release: No custom version found in config.xml - using plugin default
cordova-android-play-services-gradle-release: Android platform: cordova-android#7
cordova-android-play-services-gradle-release: No custom version found in config.xml - using plugin default
cordova-android-support-gradle-release: Android platform: cordova-android#7
cordova-android-support-gradle-release: No custom version found in config.xml - using plugin default
Preparing Firebase on Android
ANDROID_HOME=C:\Users\Boogaloo\AppData\Local\Android\sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_171
studio
Subproject Path: CordovaLib
Subproject Path: app
publishNonDefault is deprecated and has no effect anymore. All variants are now published.
cordova-android-firebase-gradle-release: 15.0.0
cordova-android-play-services-gradle-release: 15.0.0
cordova-android-support-gradle-release: 27.+
Configuration 'compile' in project ':app' 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_8vin5yy2zwz3fxyzepqpp0rqu.run(C:\Users\Boogaloo\WebstormProjects\IONIC\projects\myapp\platforms\android\app\build.gradle:151)
FAILURE: Build failed with an exception.
Where:
Script 'C:\Users\Boogaloo\WebstormProjects\IONIC\projects\myapp\platforms\android\cordova-plugin-intercom\savings-build-extras-intercom.gradle' line: 71
What went wrong:
A problem occurred configuring project ':app'.
Could not resolve all dependencies for configuration ':app:compile'.
Could not find com.google.android.gms:strict-version-matcher-plugin:15.0.0.
Searched in the following locations:
file:/C:/Users/Boogaloo/AppData/Local/Android/Sdk/extras/m2repository/com/google/android/gms/strict-version-matcher-plugin/15.0.0/strict-version-matcher-plugin-15.0.0.pom
file:/C:/Users/Boogaloo/AppData/Local/Android/Sdk/extras/m2repository/com/google/android/gms/strict-version-matcher-plugin/15.0.0/strict-version-matcher-plugin-15.0.0.jar
file:/C:/Users/Boogaloo/AppData/Local/Android/Sdk/extras/google/m2repository/com/google/android/gms/strict-version-matcher-plugin/15.0.0/strict-version-matcher-plugin-15.0.0.pom
file:/C:/Users/Boogaloo/AppData/Local/Android/Sdk/extras/google/m2repository/com/google/android/gms/strict-version-matcher-plugin/15.0.0/strict-version-matcher-plugin-15.0.0.jar
file:/C:/Users/Boogaloo/AppData/Local/Android/Sdk/extras/android/m2repository/com/google/android/gms/strict-version-matcher-plugin/15.0.0/strict-version-matcher-plugin-15.0.0.pom
file:/C:/Users/Boogaloo/AppData/Local/Android/Sdk/extras/android/m2repository/com/google/android/gms/strict-version-matcher-plugin/15.0.0/strict-version-matcher-plugin-15.0.0.jar
https://jcenter.bintray.com/com/google/android/gms/strict-version-matcher-plugin/15.0.0/strict-version-matcher-plugin-15.0.0.pom
https://jcenter.bintray.com/com/google/android/gms/strict-version-matcher-plugin/15.0.0/strict-version-matcher-plugin-15.0.0.jar
https://maven.google.com/com/google/android/gms/strict-version-matcher-plugin/15.0.0/strict-version-matcher-plugin-15.0.0.pom
https://maven.google.com/com/google/android/gms/strict-version-matcher-plugin/15.0.0/strict-version-matcher-plugin-15.0.0.jar
https://repo1.maven.org/maven2/com/google/android/gms/strict-version-matcher-plugin/15.0.0/strict-version-matcher-plugin-15.0.0.pom
https://repo1.maven.org/maven2/com/google/android/gms/strict-version-matcher-plugin/15.0.0/strict-version-matcher-plugin-15.0.0.jar
https://dl.google.com/dl/android/maven2/com/google/android/gms/strict-version-matcher-plugin/15.0.0/strict-version-matcher-plugin-15.0.0.pom
https://dl.google.com/dl/android/maven2/com/google/android/gms/strict-version-matcher-plugin/15.0.0/strict-version-matcher-plugin-15.0.0.jar
Required by:
project :app > com.google.gms:google-services:4.2.0
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 3s
(node:3432) UnhandledPromiseRejectionWarning: Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
Where:
Script 'C:\Users\Boogaloo\WebstormProjects\IONIC\projects\myapp\platforms\android\cordova-plugin-intercom\savings-build-extras-intercom.gradle' line: 71
What went wrong:
A problem occurred configuring project ':app'.
Could not resolve all dependencies for configuration ':app:compile'.
Could not find com.google.android.gms:strict-version-matcher-plugin:15.0.0.
Searched in the following locations:
file:/C:/Users/Boogaloo/AppData/Local/Android/Sdk/extras/m2repository/com/google/android/gms/strict-version-matcher-plugin/15.0.0/strict-version-matcher-plugin-15.0.0.pom
file:/C:/Users/Boogaloo/AppData/Local/Android/Sdk/extras/m2repository/com/google/android/gms/strict-version-matcher-plugin/15.0.0/strict-version-matcher-plugin-15.0.0.jar
file:/C:/Users/Boogaloo/AppData/Local/Android/Sdk/extras/google/m2repository/com/google/android/gms/strict-version-matcher-plugin/15.0.0/strict-version-matcher-plugin-15.0.0.pom
file:/C:/Users/Boogaloo/AppData/Local/Android/Sdk/extras/google/m2repository/com/google/android/gms/strict-version-matcher-plugin/15.0.0/strict-version-matcher-plugin-15.0.0.jar
file:/C:/Users/Boogaloo/AppData/Local/Android/Sdk/extras/android/m2repository/com/google/android/gms/strict-version-matcher-plugin/15.0.0/strict-version-matcher-plugin-15.0.0.pom
file:/C:/Users/Boogaloo/AppData/Local/Android/Sdk/extras/android/m2repository/com/google/android/gms/strict-version-matcher-plugin/15.0.0/strict-version-matcher-plugin-15.0.0.jar
https://jcenter.bintray.com/com/google/android/gms/strict-version-matcher-plugin/15.0.0/strict-version-matcher-plugin-15.0.0.pom
https://jcenter.bintray.com/com/google/android/gms/strict-version-matcher-plugin/15.0.0/strict-version-matcher-plugin-15.0.0.jar
https://maven.google.com/com/google/android/gms/strict-version-matcher-plugin/15.0.0/strict-version-matcher-plugin-15.0.0.pom
https://maven.google.com/com/google/android/gms/strict-version-matcher-plugin/15.0.0/strict-version-matcher-plugin-15.0.0.jar
https://repo1.maven.org/maven2/com/google/android/gms/strict-version-matcher-plugin/15.0.0/strict-version-matcher-plugin-15.0.0.pom
https://repo1.maven.org/maven2/com/google/android/gms/strict-version-matcher-plugin/15.0.0/strict-version-matcher-plugin-15.0.0.jar
https://dl.google.com/dl/android/maven2/com/google/android/gms/strict-version-matcher-plugin/15.0.0/strict-version-matcher-plugin-15.0.0.pom
https://dl.google.com/dl/android/maven2/com/google/android/gms/strict-version-matcher-plugin/15.0.0/strict-version-matcher-plugin-15.0.0.jar
Required by:
project :app > com.google.gms:google-services:4.2.0
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 3s
at ChildProcess.whenDone (C:\Users\Boogaloo\WebstormProjects\IONIC\projects\myapp\platforms\android\cordova\node_modules\cordova-common\src\superspawn.js:169:23)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at maybeClose (internal/child_process.js:925:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
(node:3432) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:3432) [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.
Update
I tried updating the cordova android platform to 7.1.0 but it hasn't helped.
I can't seem to delete the cordova firebase plugin using the command
ionic cordova plugin remove cordova-plugin-firebase
Do you use cordova-plugin-firebase?
If so,
run ionic cordova plugin remove cordova-plugin-firebase and try building again.
If it works, ionic cordova plugin add cordova-plugin-firebase#2.0.5

Cordova build to Android error

I made an app with Construct 2 and I exported to Intel XDK. Then I exported to cordova and everytime I try to build with "cordova build android" I get this error:
ERROR: In FontFamilyFont, unable to find attribute android:t
tcIndex
FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':processDebugResources'.
com.android.ide.common.process.ProcessException: Failed to execute aapt
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.
BUILD FAILED
Total time: 47.337 secs
Command finished with error code 1: cmd /s /c "C:\Users\Gustavo\app\platfo
rms\android\gradlew.bat cdvBuildDebug -b C:\Users\Gustavo\app\platforms\an
droid\build.gradle -Dorg.gradle.daemon=true -Dorg.gradle.jvmargs=-Xmx2048m -Pand
roid.useDeprecatedNdk=true"
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.
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:fontVariationSettings
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:ttcIndex
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':processDebugResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt
It's my first time posting here, so if I am doing something wrong, please tell me.
Thanks for the help!
I got a build successful by adding this in the build-extras.gradle file:
configurations.all {
resolutionStrategy {
force 'com.android.support:support-v4:27.1.0'
}
}
And by installing the cordova-android-support-gradle-release.
Gustavo,
Its is possible that you have a conflict in cordova plugins or platform. A second possiblity is that, you have added components via npm but haven't installed it. For both scenario, I suggest that you list out the current versions installed, note them down then do an update to cordova. Here is how to list out the versions, like what I have.
cd projectfolder
$ cordova plugin
cordova-plugin-console 1.1.0 "Console"
cordova-plugin-device 2.0.1 "Device"
cordova-plugin-whitelist 1.3.3 "Whitelist"
$ cordova platform
Installed platforms:
android 7.0.0
browser 5.0.3
Available platforms:
ios ~4.5.4
osx ~4.0.1
windows ~5.0.0
www ^3.12.0
$ npm -v
3.10.10
Here is how you update cordova for the project. This example assumes you are using android platform. If you have other plugins/platform, do the necessary.
npm install
npm update
cordova platform rm android --nosave
cordova platform add android
Alternatively
cordova platform update android
If you notice a specific plugin with version error, remove and the plugin with required version.

How to build android version 6.4.0 with crosswalk plugin?

I trying to build android version 6.4.0 after install crosswalk plugin version 2.4.0.
First I removed the android platform and I reinstalled it using the following commands:
ionic cordova platform rm android
ionic cordova platform add android#6.4.0
The installation is succeeded.
Moreover, I installed the crosswalk plugin using the following command line:
ionic cordova plugin add cordova-plugin-crosswalk-webview
Also the installation is succeeded
Now I need to build the ionic2 application!
ionic cordova build android
But the building is failed I got the following errors:
> cordova build android
ANDROID_HOME=/Users/Khaled/Library/Android/sdk
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_162.jdk/Contents/Home
Subproject Path: CordovaLib
Configuration 'compile' in project ':' is deprecated. Use 'implementation' instead.
null
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_cobuqw2y8dlztu9fe2xpnvg13.run(/Users/Khaled/iCloud Drive (Archive)/Documents/Projects/ionic/rnb/rnb-receiver/platforms/android/build.gradle:143)
org.xwalk:xwalk_core_library:23+
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
>
All flavors must now belong to a named flavor dimension. Learn more at https://d.android.com/r/tools/flavorDimensions-missing-error-message.html
* 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 1s
(node:21899) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: /Users/Khaled/iCloud Drive (Archive)/Documents/Projects/ionic/rnb/rnb-receiver/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> All flavors must now belong to a named flavor dimension. Learn more at https://d.android.com/r/tools/flavorDimensions-missing-error-message.html
* 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 1s
(node:21899) [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.
cordova version 8.0.0
What is the reason for this error occurrence. and what is the solution?
Thanks.

Categories

Resources