Ionic AngularJS build android on ubuntu - android

I created mobile application with Ionic. I want build application and I've a problem, I try build application on Vagrant but I get response error.
ERROR: Error: Failed to find 'ANDROID_HOME' environment variable. Try
setting setting it manually. Failed to find 'android' command in your
'PATH'. Try update your 'PATH' to include path to valid SDK directory
My .profile:
export ANDROID_HOME="/usr/local/android-sdk-linux/tools" export
ANDROID_PLATFORM_TOOLS="/usr/local/android-sdk-linux/platform-tools"
export PATH="$PATH:$ANDROID_HOME:$ANDROID_PLATFORM_TOOLS"
ANDROID_HOME=/opt/android-sdk-linux
ANDROID_PLATFORM_TOOLS=/opt/android-sdk-linux/platform-tools
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/u$
ANDROID_SDK=/opt/android-sdk-linux
How fix? Any ideas?

I think you may try this
export ANDROID_HOME=/installation-location/android-sdk-linux
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
Look to the source for more details

Related

Android Error: Failed to find 'ANDROID_HOME' environment variable

I just started Android development with ionic framework on Linux (Ubuntu).
I successfully created my ionic project using the command:
sudo ionic start demo blank
Now to add the android platform to the project, I ran the command:
sudo ionic platform add android
And this is the result it gave me:
function bold() { [native code] } https://github.com/driftyco/ionic-default-resources/archive/master.zip
[=============================] 100% 0.0s
Adding android project...
Creating Cordova project for the Android platform:
Path: platforms/android
Package: com.ionicframework.demo504884
Name: demo
Activity: MainActivity
Android target: android-24
Subproject Path: CordovaLib
Android project created with cordova-android#6.0.0
ls: no such file or directory: /home/awa/Desktop/mobile/demo/res/mipmap-*
Installing "cordova-plugin-console" for android
Failed to install 'cordova-plugin-console':CordovaError: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.
at /home/awa/Desktop/mobile/demo/platforms/android/cordova/lib/check_reqs.js:222:19
at _fulfilled (/home/awa/Desktop/mobile/demo/platforms/android/cordova/node_modules/q/q.js:834:54)
at self.promiseDispatch.done (/home/awa/Desktop/mobile/demo/platforms/android/cordova/node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (/home/awa/Desktop/mobile/demo/platforms/android/cordova/node_modules/q/q.js:796:13)
at /home/awa/Desktop/mobile/demo/platforms/android/cordova/node_modules/q/q.js:857:14
at runSingle (/home/awa/Desktop/mobile/demo/platforms/android/cordova/node_modules/q/q.js:137:13)
at flush (/home/awa/Desktop/mobile/demo/platforms/android/cordova/node_modules/q/q.js:125:13)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickCallback (internal/process/next_tick.js:98:9)
Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.
At first I doubted if it had successfully added the android platform so I ran the same command again (sudo platform add android) and it said platform already existed.
Now seeing the last section of the error, I set the ANDROID_HOME environment variable by putting this code at the end of my .bashrc file located my home directory.
export ANDROID_HOME=/home/awa/Android/Sdk
export PATH=$PATH:/home/awa/Android/Sdk/tools
export PATH=$PATH:/home/awa/Android/Sdk/platform-tools
I saved the file. In order to build my project, I ran the command:
sudo ionic build android
and it gave the error:
add to body class: platform-android
Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.
I verified again to make sure I had succeeded in setting the ANDROID_HOME environment variable correctly. So in the Command line I ran the command echo $ANDROID_HOME and it gave as output:
/home/awa/Android/Sdk
...which is the right directory for my SDK.
I have tried other solutions like setting the environment variables in the .profile file but nothing changed.
Now I am suspecting the problem may have something to do with my sdk version though I'm not entirely sure.
What am I doing wrong, or what I'm I missing?

How can I set the 'ANDROID_HOME' environment variable?

I am done with my requirements and I am unable to build my app. It is simply throwing an error like:
Error: Failed to find 'ANDROID_HOME' environment variable.
Try setting setting it manually.
Failed to find 'android' command in your 'PATH'.
Try update your 'PATH' to include path to valid SDK directory.
Can anyone suggest me how to rectify?
Include the below lines in .bash_profile file:
export ANDROID_HOME=/YOUR_PATH_TO/Library/Android/sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
export PATH=/usr/local/bin:$PATH

PhoneGap - Cordova build android faild

I'm new in phonegap. I have this problem when I try to build with cordova :
sudo cordova build android
Here is the log :
Running command: /home/paul/Documents/Projets/tozer0-app/platforms/android/cordova/build
[Error: Failed to find 'JAVA_HOME' environment variable. Try setting setting it manually.]
ERROR building one of the platforms: Error: /home/paul/Documents/Projets/tozer0-app/platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: /home/paul/Documents/Projets/tozer0-app/platforms/android/cordova/build: Command failed with exit code 2
Any idea ?
Just add the JAVA_HOME , ANDROID_HOME and ANT_HOME to path and point out the corresponding bin directory as:
For android studio
add this into your ~/.bashrc file:
export ANDROID_HOME=/path/to/android/SDK
export PATH=$PATH:$ANDROID_HOME/bin
you can do the same for Ant.
For java jdk
add this into your /etc/profile file:
JAVA_HOME=/path/to/jdk
JRE_HOME=$JAVA_HOME/jre
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH
Now in your terminal, type echo $PATH and make sure all the environment variables are added to the PATH!

Failed to find 'ANDROID_HOME' environment variable. Failed to find 'android' command in your 'PATH'

I'm trying to build the default Hello World phonegap project for android on my ubuntu system, but I am confronted by errors at every step.
SHORT VERSION:
I cannot create a phonegap project without sudo (not quite true--see below).
After creating a phonegap project with sudo, I cannot build android without sudo.
When I type "sudo phonegap build android", I lose my path settings, resulting in an error.
I have attempted a fix for this last problem by including the line "alias sudo='sudo env PATH=$PATH'" in.bashrc, as suggested in sudo changes PATH - why?, but it doesn't work. I also added ANDROID_HOME and PATH lines to .bash_profile, with no success.
I think the 'android' command actually is in my path.
Here are the last lines of my .bashrc:
export PATH="$HOME/Android/tools:$PATH"
export PATH="$HOME/Android/platform-tools:$PATH"
export ANDROID_HOME="$HOME/Android:$PATH"
alias sudo='sudo env PATH=$PATH'
I also have the following in ~/.bash_profile:
export PATH="$HOME/Android/tools:$PATH"
export PATH="$HOME/Android/platform-tools:$PATH"
export ANDROID_HOME="$HOME/Android:$PATH"
LONG VERSION:
gregory#gregory-1001PXD:~/javascript$ phonegap create phonetest
Error: EACCES, permission denied '/home/gregory/.config/configstore/update-notifier-cordova.json'
You don't have access to this file.
at Object.fs.openSync (fs.js:432:18)
at Object.fs.readFileSync (fs.js:286:15)
at Object.create.all.get (/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/update-notifier/node_modules/configstore/index.js:34:26)
at Object.Configstore (/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/update-notifier/node_modules/configstore/index.js:27:44)
at new UpdateNotifier (/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/update-notifier/index.js:34:17)
at module.exports (/usr/local/lib/node_modules/phonegap/node_modules/cordova/node_modules/update-notifier/index.js:123:23)
at checkForUpdates (/usr/local/lib/node_modules/phonegap/node_modules/cordova/src/cli.js:64:20)
at cli (/usr/local/lib/node_modules/phonegap/node_modules/cordova/src/cli.js:114:5)
at Object.<anonymous> (/usr/local/lib/node_modules/phonegap/node_modules/cordova/bin/cordova:41:1)
at Module._compile (module.js:456:26)
gregory#gregory-1001PXD:~/javascript$ sudo phonegap create phonetest
[sudo] password for gregory:
Creating a new cordova project.
gregory#gregory-1001PXD:~/javascript$ cd phonetest/
gregory#gregory-1001PXD:~/javascript/phonetest$ sudo phonegap build android
[phonegap] executing 'cordova build android'...
cp: no such file or directory: /home/gregory/javascript/phonetest/icon.png
Running command: /home/gregory/javascript/phonetest/platforms/android/cordova/build
[Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.]
ERROR building one of the platforms: Error: /home/gregory/javascript/phonetest/platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: /home/gregory/javascript/phonetest/platforms/android/cordova/build: Command failed with exit code 2
Bu I think the android command is in my PATH (it tab-completes).
NOTE: I can create a project without sudo if I remove the file update-notifier-cordova.json. But it still produces an error, as follows.
gregory#gregory-1001PXD:~/javascript$ sudo mv /home/gregory/.config/configstore/update-notifier-cordova.json ~/Documents/
gregory#gregory-1001PXD:~/javascript$ phonegap create phonetest
Creating a new cordova project.
gregory#gregory-1001PXD:~/javascript$ cd phonetest/
gregory#gregory-1001PXD:~/javascript/phonetest$ phonegap build android
[phonegap] executing 'cordova platform add --save android'...
Error: Failed to fetch platform android#~4.1.0
Probably this is either a connection problem, or platform spec is incorrect.
Check your connection and platform name/version/URL.
Error: EACCES, open '/home/gregory/.cordova/lib/npm_cache/cordova-android/4.1.1/package/.npmignore'
[phonegap] executing 'cordova build android'...
Error: No platforms added to this project. Please use `cordova platform add <platform>`.
This is documented in their JIRA: https://issues.apache.org/jira/browse/CB-10062
Check the ownership of the file using:
ls -al /home/gregory/.config/configstore/update-notifier-cordova.json
If it is root, you may want to try reinstalling cordova - otherwise use the workaround suggested by running:
chmod 744 /home/gregory/.config/configstore/update-notifier-cordova.json

[Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually

Im using Cordova in Linux mint 17
I installed android sdk , cordova , android studio , nodejs 4
problem is here
when i wanna build app in codova and run this on terminal :
sudo cordova build android
it shows
Running command: /home/tnt/hello12/platforms/android/cordova/build
[Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.]
ERROR building one of the platforms: Error: /home/tnt/hello12/platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: /home/tnt/hello12/platforms/android/cordova/build: Command failed with exit code 2
I put this code
export HOME="/home/tnt"
export ANDROID_HOME="$HOME/android/sdk/tools"
export ANDROID_PLATFORM_TOOLS="$HOME/android/sdk/platform-tools"
export PATH="$ANDROID_HOME:$ANDROID_PLATFORM_TOOLS:$PATH"
export JAVA_HOME="/usr/lib/jvm/java-7-openjdk-amd64"
export ANT_HOME="/usr/share/ant"
export PATH="$ANT_HOME/bin:$PATH"
export ANDROID_HOME="/home/tnt/android/sdk/tools"
on my
/home/tnt/.bash_profile
/home/tnt/.bashrc
/home/tnt/.profile
/root/.bash_profile
/root/.bashrc
/root/.profile
but it wont works
I don't think its necessary to add everything into path.Just add the JAVA_HOME , ANDROID_HOME and ANT_HOME to path and point out the corresponding bin directory as:
For android studio
add this into your ~/.bashrc file:
1.export ANDROID_HOME=/path/to/android/studio
2.export PATH=$PATH:$ANDROID_HOME/bin
you can do the same for Ant.
For java jdk
add this into your /etc/profile file:
1.JAVA_HOME=/path/to/jdk
2.JRE_HOME=$JAVA_HOME/jre
3.PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
4.export JAVA_HOME
5.export JRE_HOME
6.export PATH
Now in your terminal, type echo $PATH and make sure all the environment variables are added to the PATH!
You should edit /etc/sudoers with
sudo visudo
At the end of the file enter:
Defaults env_keep +="ANDROID_HOME"

Categories

Resources