code not running on device/emulator - android

I m new to cordova/ionic.
I have a cordova project which i want to run either on android device or emulator.
When i run the command : ionic cordova run android.
I get the following error :
Detected locally installed Ionic CLI, but it's too old--using global
CLI.
cordova platform add android --save Using cordova-fetch for cordova-android#7.0.0 Error: Failed to fetch platform
cordova-android#7.0.0 Probably this is either a connection problem, or
platform spec is incorrect. Check your connection and platform
name/version/URL. Error: cmd: Command failed with exit code 1 Error
output:
in the code platform android already exists, but when i check its version it i s, android~6.3.0.
I have tried a number of things to resolve it which includes, reinstalling cordova, android.
Can anyone have a solution for it.
The code was written around a year back and now i have all the latest versions installed in my system

Problem is android platform was not added properly. Therefore you have to add respective Android Platform into your Project.
Before adding run :
cordova platform remove android
After run :
cordova platform add android#6.0.0
if you develop on windows enviroment You can check the version of Android provided by Cordova under :
C:/Users/%USER%/.cordova/lib/npm-cache/cordova-android
You may also want to try adding --nofetch to the command, which will use the pre-7.x behavior. See Cordova 7 fails to add android platform

You can try it by firstly updating your android sdk manager with all the latest updates and also update its gradle. Then try to firstly remove the android platform using command
CORDOVA PLATFORM REM ANDROID
and then add android platform using command
CORDOVA PLATFORM ADD ANDROID.

Related

to what was "ionic platform add android" command renamed to?

I am starting to learn Ionic, and on building my first application, when typing the
# ionic platform add android
it says that the command has been renamed. My question is, what was it changed with?
In the tutorial I follow, it says to execute the commands
# ionic platform add android
# ionic build android
# ionic run android
On searching the web, I have come across the command
# ionic cordova run android
and it also said that cordova was moved to a CLI which also has to be installed.
But what about "add" and "build"? They are not required anymore?
Thank you.
I believe you are using latest Ionic version, 3.6.0 and above. Since then Ionic cli commands have renamed from
ionic platform add android to ionic cordova platform add android
For all the commands append cordova after ionic keyword.
For list of command, refer to the documentation here at https://ionicframework.com/docs/cli/
Your tutorial commands are outdated. But you can still follow them, but just append cordova after ionic keyword
ionic platform add android becomes ionic cordova platform add android
ionic build android becomes ionic cordova build android
ionic run android becomes ionic cordova run android
"But what about "add" and "build"? They are not required anymore?" - You still need them for adding platforms/plugins.
add is used for adding platforms/plugins. For ex: To add ios platform you use ionic cordova platform add ios
build is used for Build (prepare + compile) an Ionic project for a given platform. For ex: To build ios you need ionic cordova build ios
Note: you can replace ios with android or vise versa in any of the above commands.
Since you started learning check this website out, might be a good place to start - https://ionicacademy.com/
Now "ionic" is renamed with "ionic cordova".
So use:
ionic cordova platform add android
ionic cordova run android
***for run on windows****
ionic cordova platform add browser
ionic serve

How to convert the ionic project in to android app

i had build the ionic project (sample in 'www' folder) and run the sample in browser. but i need to convert the sample/project in to android app, and want to test that sample in my android phone. please provide what are all the software needed to do this and what are all the step by step procedure.
You will need the Android SDK to compile Android code. Set ANDROID_HOME environment variable to the SDK location.
On windows: set ANDROID_HOME=/path/to/sdk
From the command line, run the following command which generates an Android project:
ionic add platform android
Then build an apk file using this command:
ionic build android
Copy the apk to an Android device for testing.
The next step after starting an ionic project and building the app is deployment.
Make sure your device connected to your machine. Make sure android ionic support is enabled via $ionic platform add android. Check that android is supported via $ionic platform list.
Then build your app.
$ionic build android and run it $ionic run android
This should run to the connected device to test. You can also use emulators by adjusting the run syntax.

Ionic build platform override

I have build platform for android and ios at starting of the app.
I want to override android and ios build after some completion of the project.
command I'm using:
ionic platform build android
and it's giving error:
error: Platform "build" not recognized as as core cordova platform. See 'cordova platform list'.
I have tried even:
cordova platform build android
it's showing Available platforms. But apk file is not getting overridden.
What should I do to get a latest apk build output.
The build command is:
ionic build android
I am also facing this error but after uninstall all the ngCordova plugin and reinstall all, then i got No Error.

Setting Android Home path in ionic framework

I want to run my ionic project in android device.So I ran following commands
Ionic add ionic-platform-web-client
ionic plugin add phonegap-plugin push
ionic io init
ionic platform add android
All the above commands were successfully executed.When I tried to run following command:
ionic run android
It gives me error:
'ANDROID_HOME' environment variable is set to non-existent path.
Try update it manually to point to valid SDK directory.
You may not have the required environment or OS to run this project.
How do i fix it now?
Try ionic build android before android run android
Just set you windows environment for the correct android home path

Cordova build android

When I want to try ionic weather app (https://github.com/driftyco/ionic-weather/) I've got problems when I wanted to build android to my phone-gap application using cordova. I receive this message in terminal when I execute the command cordova build android
Error: An error occurred while listing Android targets
I work on ubuntu 13.10
I was able to successfully build the project with the following steps:
npm install -g cordova ionic
git clone https://github.com/driftyco/ionic-weather/
cd ionic-weather
cordova platform add android
cordova build android
You may be missing the required android sdk tools, or they may not have been added to your system path.
Refer to this question
cordova ubuntu: An error occurred while listing Android targets
And follow this guide to ensure your environment was setup correctly.

Categories

Resources