Can't emulate ionic project on android - ionic-framework

Im new to Ionic dev , im trying to emulate an ionic app on android virtual machine , i installed cordova, node , and the android platfrom for my project . Now when i type : ionic cordova emulate android
i get this on the cmd :
> cordova emulate android
Android Studio project detected
ANDROID_HOME=C:\Users\Louay Baccary\AppData\Local\Android\sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_60
studio
Subproject Path: CordovaLib
Subproject Path: app
publishNonDefault is deprecated and has no effect anymore. All variants are now published.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':CordovaLib'.
> No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android
* 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
cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':CordovaLib'.
> No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android
* 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
[ERROR] An error occurred while running subprocess cordova.
cordova emulate android exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
this is the output after typing ionic info on my cmd:
Ionic:
ionic (Ionic CLI) : 4.10.3 (C:\Users\Louay Baccary\AppData\Roaming\npm\node_modules\ionic)
Ionic Framework : #ionic/angular 4.0.1
#angular-devkit/build-angular : 0.12.4
#angular-devkit/schematics : 7.2.4
#angular/cli : 7.2.4
#ionic/angular-toolkit : 1.4.0
Cordova:
cordova (Cordova CLI) : 8.1.2 (cordova-lib#8.1.1)
Cordova Platforms : android 7.1.4
Cordova Plugins : not available
System:
NodeJS : v10.15.1 (C:\Program Files\nodejs\node.exe)
npm : 6.4.1
OS : Windows 10
I tried to run cmd as an administrator also , tried to check the android sdk manager , i fully updated my android studio but i still get the same result.

Related

Unable to build android in IONIC 6

When I run ionic cordova build android –prod i get the error:
Downloading https://services.gradle.org/distributions/gradle-7.1.1-all.zip
Exception in thread "main" java.io.IOException: Downloading from https://services.gradle.org/distributions/gradle-7.1.1-all.zip failed: timeout
I'm behind a proxy, so I set
ionic config set -g proxy http://proxy-..***:9999
I have executed ionic start myApp tabs --cordova --type=angular
I have executed ionic serve
but i can't do the build
I will be very grateful if you can help me please.
Ionic:
Ionic CLI: 6.20.3
Ionic Framework: #ionic/angular 6.3.2
Cordova:
Cordova CLI: 11.0.0
Cordova Platforms: android 10.1.2
Utility:
cordova-res: not installed globally
native-run: not installed globally
System:
NodeJS: v16.17.0 (C:\Program Files\nodejs\node.exe)
npm: 8.15.0
OS: Windows 10
Make sure you already added android in your ionic app then proceed on these steps.
Download the gradle: https://services.gradle.org/distributions/gradle-7.1.1-all.zip
Place the zip file inside: {YourAppName}/platforms/android/gradle
Set an environment variable in your OS: CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL="../gradle-7.1.1-all.zip"
Run ionic cordova build android --prod

Problems when building in ionic cordova android

What went wrong:
A problem occurred configuring project ':CordovaLib'.
No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android
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
cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring project ':CordovaLib'.
No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android
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
[ERROR] An error occurred while running subprocess cordova.
cordova build android --release exited with exit code 1.
Re-running this command with the --verbose flag may provide more information
I had the same problem and I tried many things.
I updated everything I could in Android Studio and SDK Manager. Gradle and Android Gradle Plugin got updated in the process - but this didn't help.
Then I updated cordova (from 8.1.2 to 9.0.0) and cordova-android (to 8.0.0) to latest versions - but this in itself didn't help either.
Only removing and re-adding android platform finally solved the issue:
npm install -g cordova#latest
npm install cordova-android#latest --save
ionic cordova platform remove android
ionic cordova platform check android
ionic cordova platform add android
Upgrade your version of cordova-android to the latest 7.1.3 and it will use the gradle plugin for android v3.3 which no longer checks for mips abi in the NDK.
also make sure to set the ANDROID_NDK_HOME environment variable to the location of your NDK.
Did two steps
1.Set ANDROID_HOME_NDK
2.Updated as answered by zbyl
npm install -g cordova#latest
npm install cordova-android#latest --save
ionic cordova platform remove android
ionic cordova platform check android
ionic cordova platform add android
And it worked.

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!

Ionic 3 error adding plugin cordova geolocation

When i add to my ionic project the cordova geolocation plugin, with this command:
ionic cordova plugin add cordova-plugin-geolocation --variable GEOLOCATION_USAGE_DESCRIPTION="To locate you"
i got this error:
BUILD FAILED
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Total time: 1.296 secs
Failed to install 'cordova-plugin-geolocation': Error: cmd: Command failed with exit code 1
at ChildProcess.whenDone
(D:\Usuarios.....\platforms\android\cordova\node_modules\cordova-common\src\superspawn.js:169:23)
at emitTwo (events.js:106:13)
at ChildProcess.emit (events.js:191:7)
at maybeClose (internal/child_process.js:885:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
Error: cmd: Command failed with exit code 1
[ERROR] An error occurred while running cordova plugin add cordova-plugin-geolocation --variable
"GEOLOCATION_USAGE_DESC... (exit code 1).
What´s happening??
Solved by removing plugin
ionic cordova remove cordova-plugin-geolocation
and removing android platform
ionic cordova remove platform android
so, adding the plugin again
ionic cordova plugin add cordova-plugin-geolocation --variable GEOLOCATION_USAGE_DESCRIPTION="To locate you"
and the android
ionic cordova add platform android
Some bug in the way...

Ionic Android build failed with an exception

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