Ionic Android build failed with an exception - ionic-framework

I got the following error in the implementation of the Ionic. How do I fix this error?
windows: 10
ionic: 2.2.3
cordova: 6.5.0
Morteza#DESKTOP-ORPCJPP MINGW64 /d/ionic/Morteza (master)
$ ionic run android
> ionic-hello-world#0.0.0 ionic:build D:\ionic\Morteza
> ionic-app-scripts build
ANDROID_HOME=C:\Users\Morteza\AppData\Local\Android\sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_25
Subproject Path: CordovaLib
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:2.2.1.
Required by:
:android:unspecified
> Could not resolve com.android.tools.build:gradle:2.2.1.
> Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.pom'.
> Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/2.2.1/gradle-2.2.1.pom'.
> Connect to jcenter.bintray.com:443 [jcenter.bintray.com/75.126.118.188] failed: Connection timed out: connect
* 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: 25.67 secs
Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

Try this:
Into your android sdk find sdk manager.
open sdk manager with Run as administrator.
now download android sdk build tools matching version with your ionic
also download android api->sdk platform matching version with your ionic

Related

Gradle Version in VSCode running Flutter app

I've install the VSCode, Android Studio, and Flutter in my windows. when I try to launch the android emulator (Pixel 4 API TiramisuPrivacySandbox) and Run the app ( default test app generated in VSCode - click counter) I get an error:
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'android'.
Could not resolve all files for configuration ':classpath'.
Could not find com.android.tools.build:gradle:7.1.2.
Searched in the following locations:
https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/7.1.2/gradle-7.1.2.pom
https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/7.1.2/gradle-7.1.2.pom
Required by:
project :
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 31s
Exception: Gradle task assembleDebug failed with exit code 1
** in gradle-wrapper.properties file, the gradle version is 7.4
> distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
** in build.gradle file, the gradle version is 7.1.2
> dependencies {
> classpath 'com.android.tools.build:gradle:7.1.2'
> classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
> }`
** in web or windows devices, it runs without error.
Internet Issue ,Check your Internet Connection
if your internet is ok still having this issue then you need to change the internet connection (can use VPN) and try again hope it will work

hello im try to run my flutter app on my real android phone but give me a lot of errors

Launching lib\main.dart on STK L21 in debug mode...
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'android'.
Could not resolve all artifacts for configuration ':classpath'.
Could not resolve com.android.tools.build:gradle:4.1.0.
Required by:
project :
> Could not resolve com.android.tools.build:gradle:4.1.0.
> Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/4.1.0/gradle-4.1.0.pom'.
> Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/4.1.0/gradle-4.1.0.pom'. Received status code 403 from server: Forbidden
Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50.
Required by:
project :
> Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50.
> Could not get resource 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.3.50/kotlin-gradle-plugin-1.3.50.pom'.
> Could not GET 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-gradle-plugin/1.3.50/kotlin-gradle-plugin-1.3.50.pom'. Received status code 403 from server: Forbidden
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 1m 5s
Exception: Gradle task assembleDebug failed with exit code 1
How to Solve Flutter problems: “Could not resolve all artifacts for configuration ':classpath' ” Error?
To Solve Flutter problems: “Could not resolve all artifacts for configuration ':classpath' ” this problem is caused by updating the Gradle. The Android Studio always asks you to update it, but don't do this for flutter apps. I solved it with the following versions On build.gradle module level.
Flutter problems: “Could not resolve all artifacts for configuration ':classpath' ” Error
To Solve Flutter problems: “Could not resolve all artifacts for configuration ':classpath' ” this problem is caused by updating the Gradle. The Android Studio always asks you to update it, but don't do this for flutter apps. I solved it with the following versions On build.gradle module level
please follow this link :https://fluttercorner.com/flutter-problems-could-not-resolve-all-artifacts-for-configuration-classpath/
First You run Flutter Doctor

ionic 4 beta No installed build tools found

I’m trying to compile android apk, but I get the error “No installed build tools found.”
$ ionic cordova build android
Error:
...
Android Studio project detected
Preparing Firebase on Android
ANDROID_HOME=/usr/lib/android-sdk
JAVA_HOME=/usr/lib/jvm/java-8-oracle
studio
Subproject Path: CordovaLib
Subproject Path: app
FAILURE: Build failed with an exception.
* Where:
Script '/home/ubuntu/lapp/platforms/android/CordovaLib/cordova.gradle' line: 68
* What went wrong:
A problem occurred evaluating project ':CordovaLib'.
> No installed build tools found. Install the Android build tools version 19.1.0 or higher.
* 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 2s
/home/ubuntu/lapp/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* Where:
Script '/home/ubuntu/lapp/platforms/android/CordovaLib/cordova.gradle' line: 68
* What went wrong:
A problem occurred evaluating project ':CordovaLib'.
> No installed build tools found. Install the Android build tools version 19.1.0 or higher.
* 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 2s
[ERROR] An error occurred while running subprocess cordova.
cordova build android exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
Environment Variables:
export ANDROID_HOME=/home/ubuntu/Android/Sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
$ echo $ANDROID_HOME
/home/ubuntu/Android/Sdk
$ echo $JAVA_HOME
/usr/lib/jvm/java-8-oracle
$ echo $PATH
...
/usr/lib/jvm/java-8-oracle/bin:
/usr/lib/jvm/java-8-oracle/db/bin:
/usr/lib/jvm/java-8-oracle/jre/bin:
/home/ubuntu/Android/Sdk/platform-tools:
/home/ubuntu/Android/Sdk/tools:
/home/ubuntu/Android/Sdk/build-tools:
/home/ubuntu/Android/Sdk/tools/bin:
/home/ubuntu/Android/Sdk/emulator
.
$ ionic info
Ionic:
ionic (Ionic CLI) : 4.6.0 (/usr/local/lib/node_modules/ionic)
Ionic Framework : #ionic/angular 4.0.0-rc.0
#angular-devkit/build-angular : 0.11.4
#angular-devkit/schematics : 7.1.4
#angular/cli : 7.1.4
#ionic/angular-toolkit : 1.2.2
Cordova:
cordova (Cordova CLI) : not installed
Cordova Platforms : not available
Cordova Plugins : not available
System:
Android SDK Tools : 26.1.1 (/home/ubuntu/Android/Sdk)
NodeJS : v10.14.2 (/usr/local/bin/node)
npm : 6.4.1
OS : Linux 4.15
I try:
ionic cordova platform remove android
ionic cordova platform add android
After all this, I installed all the SDKs from Android 4.3 and all Android SDK build-tools from 19.0.3, but even this did not help.
Ps: No matter how I try to set the path to ANDROID_HOME (~/.bash_profile, ~/.bashrc), but still takes ANDROID_HOME=/usr/lib/android-sdk
any ideas?
1) Terminal as root
$ sudo -s
2) Add path to ~/.bash_profile or ~/.bashrc
3) Done!

Enable to execute command " ionic cordova run android " in Windows 10

FAILURE: Build failed with an exception.
Where:
Script 'C:\wamp64\www\ionic\spetinfo\platforms\android\CordovaLib\cordova.gradle' line: 64
What went wrong:
A problem occurred evaluating root project 'android'.
No installed build tools found. Install the Android build tools version 19.1.0 or higher.
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).

ionic not generating android-build

[WARN] Not performing Ionic build for project type: ionic1.
ionic cordova prepare android
cordova prepare android
Running command: "C:\Program Files\nodejs\node.exe" C:\Users\pini\Desktop\Drivercheckcall\hooks\after_prepare\010_add_platfo
rm_class.js C:\Users\pini\Desktop\Drivercheckcall
add to body class: platform-android
Running command: "C:\Program Files\nodejs\node.exe" C:\Users\pini\Desktop\Drivercheckcall\hooks\after_prepare\020_remove_sas
s_from_platforms.js C:\Users\pini\Desktop\Drivercheckcall
cordova build android --release
× Running command - failed!
[ERROR] An error occurred while running cordova build android --release (exit code 1):
Running command: "C:\Program Files\nodejs\node.exe"
C:\Users\pini\Desktop\Drivercheckcall\hooks\after_prepare\010_add_platform_class.js
C:\Users\pini\Desktop\Drivercheckcall
add to body class: platform-android
Running command: "C:\Program Files\nodejs\node.exe"
C:\Users\pini\Desktop\Drivercheckcall\hooks\after_prepare\020_remove_sass_from_platforms.js
C:\Users\pini\Desktop\Drivercheckcall
ANDROID_HOME=C:\Users\pini\AppData\Local\Android\sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_144
Subproject Path: CordovaLib
Starting a Gradle Daemon (subsequent builds will be faster)
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_yewq1sjt6kzw92w3qmfn4wt0.run(C:\Users\pini\Desktop\Drivercheckcall\platforms\android\build.gradle:1
39)
FAILURE: Build failed with an exception.
* Where:
Script
'C:\Users\pini\Desktop\Drivercheckcall\platforms\android\phonegap-plugin-push\DriverCheckCall-push.gradle' line:
38
* What went wrong:
A problem occurred evaluating root project 'android'.
> Failed to apply plugin [class 'com.google.gms.googleservices.GoogleServicesPlugin']
> For input string: "+"
* 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: 23.062 secs
Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* Where:
Script
'C:\Users\pini\Desktop\Drivercheckcall\platforms\android\phonegap-plugin-push\DriverCheckCall-push.gradle' line:
38
* What went wrong:
A problem occurred evaluating root project 'android'.
> Failed to apply plugin [class 'com.google.gms.googleservices.GoogleServicesPlugin']
> For input string: "+"
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
I have seen this issue before with push plugin or maps plugin or google plugin, it's regarding cordova plugins and their dependencies, in your case this line it's helpful.
Failed to apply plugin [class 'com.google.gms.googleservices.GoogleServicesPlugin']
For input string: "+"
:
So one fix will be: inside platforms/android open project.properties, you will have something like this
cordova.system.library.2=com.google.android.gms:play-services-maps:+
cordova.system.library.3=com.google.android.gms:play-services-location:+
Try to have the google play services to match in version, in my case after specifying the version I ended up with the file like this:
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system edit
# "ant.properties", and override values to adapt the script to your
# project structure.
#
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-25
android.library.reference.1=CordovaLib
cordova.system.library.1=com.android.support:support-v4:24.1.1+
cordova.system.library.2=com.google.android.gms:play-services-maps:11.0.1
cordova.system.library.3=com.google.android.gms:play-services-location:11.0.1
cordova.system.library.4=com.google.android.gms:play-services-location:11.0.1
cordova.system.library.5=com.android.support:support-v13:25.1.0
cordova.system.library.6=me.leolin:ShortcutBadger:1.1.17#aar
cordova.system.library.7=com.google.firebase:firebase-messaging:11.0.1
cordova.gradle.include.1=phonegap-plugin-push/custodian-push.gradle
cordova.system.library.8=com.squareup.okhttp3:okhttp:3+