Ionic Android Build Error - ionic-framework

I'm seeing these errors after fresh ionic, cordova, and JDK update installations when I do android build:
BUILD FAILED
Total time: 6.254 secs
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':processDebugResources'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'c:\Android\sdk\build-tools\24.0.2\aapt.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.
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 ':processDebugResources'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'c:\Android\sdk\build-tools\24.0.2\aapt.exe'' finished with non-zero exit value 1

You have to update to JDK 8. Looks like you have the older version 7.
Try JDK 8
and see if it helps.

I had the same problem reinstalled SDK didn't work
removed old sdk and reinstalled SDK did't work
You need to delete the android folder form the platform folder and execute
ionic run android this will reinstall the platform automatically and build from scratch. I think the cache files are the problem so that is why I think this worked.
I hope it will also work for others.

Related

FAILURE: Build failed with an exception. * Where: Script gradle\flutter.gradle' line: 1165

I developed an application using the flutter web emulator, after the application was finished I made it I want to run to the Android emulator, but there is an error like this
FAILURE: Build failed with an exception.
Where:
Script 'C:\Users\Denis\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1165
What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
Process 'command 'C:\Users\Denis\flutter\bin\flutter.bat'' 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. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 12s
Exception: Gradle task assembleDebug failed with exit code 1
previously the error was on line 1005, then I did a flutter upgrade and now the error is on line 1165
The error message you received is not very specific and can occur due to various reasons. However, the fact that the error message is referring to Gradle suggests that there is an issue with the build process of your application. Here are a few steps that you can follow to try and resolve the issue:
Check the logs: When you run the 'flutter run' command, you should see a log output in your terminal or console. Look for any error messages that may provide more details about the issue.
Clean the project: Sometimes, cleaning the project can help resolve build issues. To do this, run the following commands:
flutter clean
flutter pub get
Update dependencies: Make sure that all dependencies in your pubspec.yaml file are up to date. You can do this by running the following command:
flutter pub upgrade
Check your code: Look for any errors in your code that may be causing the build to fail. Check the line number mentioned in the error message and see if there are any issues with the code on that line. 5. Check your Gradle configuration: If none of the above steps work, you may need to check your Gradle configuration. Make sure that you have the latest version of Gradle installed and that your build.gradle file is correctly configured. If you are still unable to resolve the issue, try searching for the error message online or consider seeking help from the Flutter community or support.

Flutter app doesn't run FAILURE: Build failed with an exception

So I installed flutter and I initialized an app I run the app it
say's
Launching lib\main.dart on AOSP on IA Emulator in debug mode...
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
Where: Build file 'C:\src\projects\myapp\android\app\build.gradle' line: 26
What went wrong: A problem occurred evaluating project ':app'.
Could not open dsl generic class cache for script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle'
(C:\Users\admin.gradle\caches\7.5\scripts\6retkvb9i1tmrre8676t631o1).
Unexpected lock protocol found in lock file. Expected 3, found 0.
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 5s Exception: Gradle task assembleDebug failed with
exit code 1
so I checked if I have problem with installation with flutter doctor and it
show's this
I already have system image and when I run the program it always shows the error
and the app doesn't run I already tried setting the JAVA_HOME and copying the jbr files to
jre but still get the error. Thank you for your response
you can visit these two post to solve your problem :
1- first error : Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable. Flutter 2.0
2-for second error : Visual Studio not installed; this is necessary for Windows development

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 error when build appbundle (Script '/Users/****/Developer/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 991)

My app is running very well in debug mode. Now I am trying to build an appbundle for release, but have error.
Oops; flutter has exited unexpectedly: "Invalid argument(s): Cannot find executable for /Users//Developer/flutter/bin/cache/artifacts/engine/android-arm64-release/darwin-x64/gen_snapshot.".
A crash report has been written to /Users//AndroidStudioProjects/*********/flutter_04.log.
This crash may already be reported. Check GitHub for similar crashes.
https://github.com/flutter/flutter/issues?q=is%3Aissue+Invalid+argument%28s%29%3A+Cannot+find+executable+for+%2FUsers%2F*****%2FDeveloper%2Fflutter%2Fbin%2Fcache%2Fartifacts%2Fengine%2Fandroid-arm64-release%2Fdarwin-x64%2Fgen_snapshot.
To report your crash to the Flutter team, first read the guide to filing a bug.
https://flutter.dev/docs/resources/bug-reports
Create a new GitHub issue by pasting this link into your browser and completing the issue template. Thank you!
https://git.io/JO1nF
FAILURE: Build failed with an exception.
Where:
Script '/Users/****/Developer/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 991
What went wrong:
Execution failed for task ':app:compileFlutterBuildRelease'.
Process 'command '/Users/*****/Developer/flutter/bin/flutter'' 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. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 58s
Running Gradle task 'bundleRelease'...
Running Gradle task 'bundleRelease'... Done 58.8s
Gradle task bundleRelease failed with exit code 1
I don't nkow what to do. Thanks for those who can suggest me something.
I was able to build appbundle by running in the terminal
flutter upgrade -f
flutter channel master
flutter upgrade
But I am facing another problem: when I run in release mode, it stuck at this
Installing build/app/outputs/flutter-apk/app.apk...

ProcessException: Process "C:\Users\Ayushi Sharma\attempt\android\gradlew.bat" exited abnormally:

Error running Gradle:
ProcessException: Process "C:\Users\Ayushi Sharma\attempt\android\gradlew.bat" exited abnormally:
FAILURE: Build failed with an exception.
Where:
Build file 'C:\Users\Ayushi Sharma\attempt\android\app\build.gradle' line: 24
What went wrong:
A problem occurred evaluating project ':app'.
Failed to apply plugin [id 'com.android.application']
Minimum supported Gradle version is 5.4.1. Current version is 5.1.1. If using the gradle wrapper, try editing the
distributionUrl in C:\Users\Ayushi Sharma\attempt\android\gradle\wrapper\gradle-wrapper.properties to gradle-5.4.1-all.zip
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 0s
Command: C:\Users\Ayushi Sharma\attempt\android\gradlew.bat app:properties
Please review your Gradle project setup in the android/ folder.
Need help!!!!!!
To resolve, change com.android.tools.build:gradle:3.2.1 => com.android.tools.build:gradle:3.3.2, run flutter clean and try the build again.
According to the Gradle_release_note, the current (July 2019) version of the plugin and gradle are 3.4.2 and 5.1.1 respectively. I don't know if Flutter officially supports this version, although it seems to work on my project here and a clean build is markedly faster. The release notes cover some of the changes from 3.2.x => 3.3.x => 3.4.x.
To upgrade to the current version, edit android\gradle\wrapper\gradle-wrapper.properties to source Gradle 5.1.1, and then you're able to upgrade the Gradle plugin to 3.4.2.
Note that once gradle 5.1.1 is being used, you can still set the plugin version back to 3.2.1 to reproduce the issue.