Execution failed for task ':app:processReleaseResources'. Failed to execute aapt - ionic-framework

I get this error when I deploy my ionic app:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processReleaseResources'.
> 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.
* Get more help at https://help.gradle.org
BUILD FAILED in 12s
at ChildProcess.whenDone (C:\Users\KING WOODE\Desktop\testapp\platforms\android\cordova\node_modules\cordova-common\src\superspawn.js:169:23)
at ChildProcess.emit (events.js:160:13)
at maybeClose (internal/child_process.js:943:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)
(node:5560) 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:5560) [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.

this worked for me
cordova plugin add cordova-android-support-gradle-release

First you need to remove android platform from the project and reinstall the android platform.
remove android platform :
ionic cordova platform rm android
Install android platform :
ionic cordova platform add android
then try to build the project again, if it will not work , try to remove plugins folder and reinstall cordova plugins again.

Have a look at the cordova-android-support-gradle-release plugin. It "aligns various versions of the Android Support libraries specified by other plugins to a specific version."
Some Cordova plugins include Android Support Libraries to faciliate them. Most commonly, these are now included into the Cordova project by specifying them as Gradle dependencies (see the Cordova plugin spec documentation). (…) The problem arises when these plugins specify different versions of the support libraries. This can cause build failures to occur. (…) To resolve these version collisions, this plugin injects a Gradle configuration file into the native Android platform project, which overrides any versions specified by other plugins, and forces them to the version specified in its Gradle file.

Related

Build works on local but fails on codemagic | Execution failed for task ':app:stripDebugDebugSymbols'

I'm trying to implement a continuous deployment system to build my app and deploy to Google Play using codemagic. Doing a build works fine locally but fails remotely on codemagic.
Error summary:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:stripDebugDebugSymbols'.
> 1 exception was raised by workers:
org.gradle.process.internal.ExecException: A problem occurred starting process 'command '/usr/local/share/android-sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-strip''
Complete log:
== Building for Android ==
> flutter build appbundle --debug
Running "flutter pub get" in My_Project... 1,655ms
💪 Building with sound null safety 💪
Running Gradle task 'bundleDebug'...
[flutter_background_geolocation] Purging debug resources in release build
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/builder/programs/flutter_2_5_3/.pub-cache/hosted/pub.dartlang.org/geocoding-2.0.1/android/src/main/java/com/baseflow/geocoding/GeocodingPlugin.java uses or overrides 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 ':app:stripDebugDebugSymbols'.
> 1 exception was raised by workers:
org.gradle.process.internal.ExecException: A problem occurred starting process 'command '/usr/local/share/android-sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-strip''
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 2m 19s
Running Gradle task 'bundleDebug'... 141.1s
Gradle task bundleDebug failed with exit code 1
Build failed :|
Failed to build for Android
Current configuration on codemagic:
Flutter channel: stable
Mode: debug
Build for: Android
to fix this you need to upgrade Gradle version in android/gradle/wrapper/gradle-wrapper.properties to 6.7.1 or commit gradle wrapper to your repository if you don't have this file.
Additional to that you also might need to upgrade Android Gradle plugin in andriod/build.gradle
- classpath 'com.android.tools.build:gradle:3.5.4'
+ classpath 'com.android.tools.build:gradle:4.2.0'
WITHOUT GRADLE UPGRADE
if for some reasons you can't upgrade Gradle version you can freeze previous NDK version.
For that you can specify ndkVersion "22.1.7171670" in your build.gradle and make sure you use Java 1.8 since there is an issue with using latest Java versions.
In Codemagic you can specify Java version in environment section in your codemagic.yaml like this
workflows:
workflow-name:
environment:
ndk: r22b
java: 1.8

Flutter, Getting build error on image_picker: ^0.6.0+9

When I update my package to image_picker: ^0.6.0+9 getting build error.
I have already migrate Android X.
Error:
Launching lib/main.dart on vivo V3 in debug mode...
Initializing gradle...
Resolving dependencies...
Running Gradle task 'assembleDebug'...
D8: Program type already present: android.support.v4.media.MediaBrowserCompat$CustomActionCallback
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Program type already present: android.support.v4.media.MediaBrowserCompat$CustomActionCallback
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 2s
The Gradle failure may have been because of AndroidX incompatibilities in this Flutter app.
Finished with error: Gradle task assembleDebug failed with exit code 1
Make Sure to follow the guide to support AndroidX
https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility
For Solving Dex error
Try adding this line In your Project folder > android > app > build.gradle
add the following Line in multiDexEnabled true
inside defaultConfig
Use flutter clean command once it is done then try running your app.
Add following line in gradle.properties
android.useAndroidX=true
android.enableJetifier=true
Remove Simple Permission package.
it's because your app isn't compatible with AndroidX ,
There are 2 solution
1-create a flutter compatible with AndroidX app by using this command in your terminal
flutter create --androidx [project_name]
2-configure your app manually
Its not problem with the Image provider its something to do with the latest flutter package. To resolve this issue
Open the Android folder of your your flutter project in Android Studio
Wait for the gradle to build once the task is complete click on Refactor -> Refactor this -> Migrate to AndroidX or press Ctrl+T -> Migrate to AndroidX
Do flutter clean
And boom your good to go
If you want to do manually by twicking the gradle file here is link
https://flutter.dev/docs/development/androidx-migration
Happy Hacking

Cordova-camera plugin

When adding cordova camera plugin into my project then i am facing cordova build problem as follows:
Step 1: Adding ionic cordova camera plugins
Step 2: try to build the native app using ionic cordova build android --debug
then the following error is displaying
Task :app:transformClassesWithMultidexlistForDebug FAILED
D8: Program type already present: android.support.v4.app.ActionBarDrawerToggle$Delegate
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
com.android.build.api.transform.TransformException: Error while generating the main dex list:
Error while merging dex archives:
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Program type already present: android.support.v4.app.ActionBarDrawerToggle$Delegate
[ERROR] An error occurred while running subprocess cordova.
cordova.cmd build android --debug exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
This problem may be from your AndroidManifest.xml. Open your AndroidManifest.xml file and find android.support.v4.app.ActionBarDrawerToggle, you will find two line for this. Comment one of them and keep only one android.support.v4.app.ActionBarDrawerToggle. Then try to run again.
This will may help you.
I change cordova-camera plugin version from 4.3.0 to 4.1.0 and now it works well this may be ionic v4 plugin issue
install the latest cordova platform[
]1

Android run error by Gradle

I'm having a serious problem with Android Gradle,
I created a project, and emulated by Android, this is what happened:
commands:
ionic start simple tabs
cd simple
ionic cordova emulate android
is this a normal response, am I doing something wrong here or not?
[19:02:48] build dev finished in 13.28 s
> cordova run android
You have been opted out of telemetry. To change this, run: cordova telemetry on.
Android Studio project detected
ANDROID_HOME=G:\dl\Android\sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_162
studio
[19:02:53] lint finished in 4.70 s
Starting a Gradle Daemon (subsequent builds will be faster)
:wrapper
BUILD SUCCESSFUL
in 13s
1 actionable task: 1 executed
Subproject Path: CordovaLib
Subproject Path: app
Exception in thread "main"
java.lang.NullPointerException
at org.gradle.wrapper.PathAssembler.getDistName(PathAssembler.java:84)
at org.gradle.wrapper.PathAssembler.getDistribution(PathAssembler.java:40)
at org.gradle.wrapper.Install.createDist(Install.java:44)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
(node:2388) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: cmd: Command failed with exit code 1 Error output:
Exception in thread "main" java.lang.NullPointerException
at org.gradle.wrapper.PathAssembler.getDistName(PathAssembler.java:84)
at org.gradle.wrapper.PathAssembler.getDistribution(PathAssembler.java:40)
at org.gradle.wrapper.Install.createDist(Install.java:44)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
(node:2388) [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?
I had the same problem. I solved it by adding the variable of the Gradle address to the "path" of the system's variables, in my case: "C: \ Gradle \ gradle-4.9 \ bin"

When uninstall nativescript plugin and run 'tns run android' has failed

I'm devloping a nativescript plugin.when I want to change something with the plugin at index.js. so I uninstall the plugin and explanatory note the plugin code in app project.Then I run 'tns run android' ,It's some error display:
...
Merged dex #46 (1 defs/1.3KiB)
Merged dex #47 (1 defs/1.4KiB)
Merged dex #48 (2513 defs/3231.2KiB)
Result is 2560 defs/4103.9KiB. Took 0.1s
:buildMetadata
Exception in thread "main" java.lang.IllegalArgumentException: Class android.support.v7.widget.SnapHelper$2 conflict: D:\app\toast-test\platforms\android\build\intermediates\transforms\dex\F0F1F2\debu
at com.telerik.metadata.ClassRepo.addToCache(ClassRepo.java:21)
at com.telerik.metadata.Builder.build(Builder.java:40)
at com.telerik.metadata.Generator.main(Generator.java:44)
:buildMetadata FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':buildMetadata'.
Process 'command 'C:\Program Files\Java\jdk1.8.0_112\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.
BUILD FAILED
Total time: 41.154 secs
Command D:\app\toast-test\platforms\android\gradlew.bat failed with exit code 1
How can I rebuild my app success after delete some plugins in project?
and how to update the nativescript plugin to new version?
After removing a plugin with native dependencies in the form of .aar or .jar (those include plugins downloaded through a remote plugin repository like maven) in NativeScript 2.4 you need to re-add the platform.
tns plugin remove nativescript-plugin
tns platform remove android
tns platform add android / tns run/build android
With the coming 2.5 release clearing any traces of the old plugin will be done by the CLI and no manual steps should be required besides simply removing the plugin from your project.