Setting Android Home path in ionic framework - android

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

Related

code not running on device/emulator

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.

ionic build android : No APK file generated in Ionic 2

I just executed the command "ionic build android" on my ionic 2 project and it was done successfully it says. But there is no APK file generated. What am I supposed to do? Thanks in advance. I'm using node v6.11.2, Ionic CLI 3.7.0, cordova 7.0.1.
First create an account at ionic Io
than hit this ionic Io init in project directory
after login hit this ionic package build android
after successful your apk file store in your cloud and download it and install
The Path as mentioned before is the correct path to find your generated apk file.
yourProject/platforms/android/build/outputs/apk/android-rele‌​ase-unsigned.apk
Please check these steps if there something missing.
I. Development environment dependencies
1)You need at Least to download a java JDK 8
2)Download an Android SDK manager
3)you must Add them to the environment variables
(Windows)
i)Open environment variables
ii)ANDROID_HOME:create a new user variable with name ANDROID_HOME and add the path of the SDK manager
ex.C:\xxx\Android\sdk
iii)edit the user variable PATH value and add to it platform tools path ex. C:\xxx\Android\sdk\platform-tools
iV)JAVA_HOME:Don't forget also to edit in the user variable PATH, your old JAVA_HOME env path with the new JDK Path . ex.C:\Program Files\Java\jdk1.8.0_144
4)Globally install ionic and cordova
npm install -g ionic cordova
II. Ionic CLI for build android
5)ionic cordova platform add android
6)ionic cordova build android
N.B: there sometimes logging in issue through CLI when using this command, the next steps doesn't really make sense but it worked for me.
ionic config set backend pro -g
Retry the build process again ,if Still there a problem change to legacy and Then again back to pro
ionic config set backend legacy -g
ionic config set backend pro -g
It should work now, retry the build process again.
If still there a problem then make an app through the website of ionic
use this command with the --pro-id of your app and retry again.
ionic start --pro-id <ID>
Follow this steps
Run ionic cordova build --release android
Open android studio go to Build -> Generate Signed APK, press next
If you don't have Key store please create new one
Finish
you can find the APK under Platforms/android

Ionic 2 platform add android error

Im trying to build an android app with ionic 2. When I try to run ionic platform add android I get this error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually. Failed to find 'android' command in your 'PATH'.
Im using linux mint and already set the environment variables like this:
export ANDROID_HOME=/home/mauro/Android/Sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
When I type android in the console, the sdk manager gets started.
My ionic version is: 2.1.7
and cordova: 6.4.0
Hope anybody can help me with this issue.
Instruction 1:
After adding your ANDROID_HOME, make sure you do the below:
Restart your System or run source ~/.bash_profile
Remove Android platform from your project ionic cordova platform rm android or ionic platform rm android
Add Android platform ionic cordova platform add android
Then ionic cordova run android or ionic run android
Instruction 2:
To set your ANDROID_HOME and JAVA_HOME, follow the below steps:
Run command open ~/.bash_profile
Paste the below in the file that opens on your Text editor
export ANDROID_HOME=/usr/local/Cellar/android-sdk/24.4.1_1
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
Save - "Command S" or "Ctrl S"
Then Follow the "Instruction 1:" above
Hope this helps.....
I have the same issue. It seems to be an issue of the combination of cordova, the installed Android SDK version and the profile settings.
This is what worked for me on ubuntu 16.10:
get an older cordova that is known to work:
npm install -g cordova#4.2
(I was on 6.4.0 and 5.0.0)
in .profile:
PATH="~/Android/Sdk/platform-tools:~/Android/Sdk/tools:$PATH"
export ANDROID_HOME=~/Android/Sdk
(Seems you are good there)
I needed the latter to stop the complaining about it even while android was in my path and it also gave me meaningfull errors, which was that API 22 was missing.
Load the profile in current bash:
source ~/.profile
Type android and install SDK 22.
Exit when done and type
ionic build android
and it should work.

Error : Unable to prepare project

While trying to do a release using the following command:
code-push release-cordova myApp android
I'm getting the following error in the terminal:
Running "cordova prepare" command:
[Error] Unable to prepare project. Please ensure that this is a Cordova project and that platform "android" was added with "cordova platform add android"
Any one knows what might be wrong? The project is a cordova project created using the command:
cordova create myApp
And also has android platform added.
UPDATE :
Running cordova prepare android --verbose returns the following output :
Executing "before_prepare" hook for all plugins.
Searching PlatformJson files for differences between project vs. platform installed plugins
No differences found between project and android platform. Continuing...
Generating config.xml from defaults for platform "android"
Wrote out Android application name to "HelloCordova"
Wrote out Android package name to "io.cordova.hellocordova"
This app does not have launcher icons defined
updated project successfully
Executing "after_prepare" hook for all plugins.
Make sure your Nodejs is the last version.
code-push-cli required "child_process"
That error indicates that the current working directory didn't represent the root of a Cordova project at the time that you ran the release-cordova command. Can you make sure that you CD into the directory that contains the www, platforms, plugins, etc. directories, and then run the release-cordova command? That should do the trick for you

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