I'm trying to follow the Getting Started with Android tutorial on Windows. I'm on step 4. Setup a New Project. I type in ./create c:\projects\test com.example.test test, then receive an error:
An unexpected error occurred: ANDROID_BIN="${ANDROID_BIN:=$( which android )}" exited with 1
Deleting project...
I've modified my PATH system environment variable, adding %ANDROID_HOME%\tools and %ANDROID_HOME%\platform-tools. %ANDROID_HOME% points to c:\adt-bundle\sdk.
I can run the following commands successfully:
java
javac
ant
adb
However, running android results in -bash: android: command not found.
I'm stumped. Anyone know what I'm missing in order to be able to create Phonegap projects?
make sure you can run the commands below from your terminal:
ant -version
java -version
android -h
If you get command not found, you need to fix that first before trying to create Phonegap projects. Once you update your PATH variable, you need to restart the command prompt/terminal before be able to use those commands.
To make things easier, make sure you have ANT_HOME, JAVA_HOME and ANDROID_HOME variable defined too!
Edit:
Make sure you are using Window's command prompt and not cygwin shell.
Related
I am trying to build android apk using ionic framework.
When I enter the following command sudo ionic build android , I get the following 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. " .
But when I check ANDROID_HOME variable by typing "echo $ANDROID_HOME" , I get the valid SDK path( e.g. /home/ttnd/android-sdk-linux ) .
Find below the configuration that I have included in the bashrc file ,
export ANDROID_HOME=/home/ttnd/android-sdk-linux
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools .
I have checked all the possible links available on web but still I am unable to find the issue.
The problem is that the execution environment for the sudo command is different than the calling one. In other words, your environment variables don't get passed in.
You may be able to fix that by adding the -E option to the sudo command. There are some possible security concerns with using that option and your particular system may block you from using it. Here's a blurb from my version of the sudo man page:
The -E (preserve environment) option indicates to the security policy that the user wishes to
preserve their existing environment variables. The security policy may return an error if the -E
option is specified and the user does not have permission to preserve the environment.
Another way around it would be to to include the environment variables as part of the sudo command. Something like this:
sudo ANDROID_HOME=$ANDROID_HOME PATH=$PATH ionic build android
A third way would be to run the sudo visudo and add the variables that you'd like to be included in the sudo run environment.
I am trying to run Appium on the command line with OSX El Capitan to test an Android application. I have been able to use Appium many times with the GUI version but have not had the same luck in the terminal. The issues I am facing stem from setting the $ANDROID_HOME environment variable. I have read other posts regarding this problem but the solutions have not helped me.
I have the following in my bash_profile :
export ANDROID_HOME=/Users/adamjakiela/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
I then run source ~/.bash_profile and am able to start the SDK by running the android command. I can also print the environment variable:
echo $ANDROID_HOME
/Users/adamjakiela/Library/Android/sdk
But then, when I run Appium on the command line I receive the following message which eventually leads to other problems:
warn: The ANDROID_HOME environment variable is not set to the Android SDK root directory path.
I can also run the Appium doctor and see the following:
Running Android Checks
✖ ANDROID_HOME is not set
Appium-Doctor detected problems. Please fix and rerun Appium-Doctor.
Additionally, I have installed all the build tools for the applicable versions of Android and have had no problem build my applications or using the Appium GUI version by pointing it to the $ANDROID_HOME location.
Why are the errors shown by Appium inconsistant with the fact that the $ANDROID_HOME environment variable is set and that other applications are able to use the Android SDK?
I'm triying to build my first cordova project, when I'm inside the project folder i tip:
sudo cordova build android
and I get the following error:
[Error: ANDROID_HOME is not set and "android" command not in your PATH. You must fulfill at least one of these conditions.]
ERROR building one of the platforms: Error: /home/veritopsecret/hello/platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project
when I do echo $PATH I get:
veritopsecret#veritopsecret-SATELLITE-PRO-C50-A-1HQ:~/hello$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/veritopsecret/Escriptori/android-sdk-linux/tools:/home/veritopsecret/Escriptori/android-sdk-linux/platform-tools
I have also modified .profile file, but it stills say that it hasn't android command in the PATH. However, if I just write android, it opens the android sdk manager. Help please!!
As I re-read your question, I see you run sudo cordova build android
I think the issue you have is that you define ANDROID_HOME and add the android tools to the path of your user but then you use sudo to run the build.
sudo runs with elevated privileges using a user which is not your user profile that you are logged with, so the path and ANDROID_HOME are not set. (maybe try sudo echo $PATH to be sure of that).
So if you really wanted to use sudo to build, you would need either to define the vars for the sudo user or use instead sudo -E (see this page for more details : https://wiki.archlinux.org/index.php/Sudo#Environment_variables)
But actually, you should be using sudo only when installing cordova, not when using the CLI.
So, just run cordova build android and everything should be fine.
I've recently updated a few dependencies on my mac after a while not doing much cca development and now the "cca run android" command is no longer working on my machine.
I get the following strange error:
BUILD FAILED
<my project path>/platforms/android/build.xml:90: Cannot find /usr/local/tools/ant/build.xml imported from <my project path>/platforms/android/build.xml
Total time: 0 seconds
<my project directory>/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
Error code 1 for command: ant with args: debug,-f,<my project directory>/platforms/android/build.xml,-Dsdk.dir=/usr/local
It's looking for a build file that doesn't exist. I'm concerned about the section that says -Dsdk.dir=/usr/local. Clearly it should be looking at my android home directory, which seems to be set properly:
$ echo $ANDROID_HOME
/usr/local/opt/android-sdk
And if that variable was being set properly, it would find one:
ls $ANDROID_HOME/tools/ant/build.xml
/usr/local/opt/android-sdk/tools/ant/build.xml
Has anyone run into this recently using recent versions of cca with android? Hoping there's some obvious mistake I'm making that can be easily remedied.
I got a response from the MobileChromeApps developers on their github issue tracker. It turns out that the sdk.dir was not being set by the $ANDROID_HOME variable, but instead by the $PATH variable that matches the first android executable. By fixing my path to move $ANDROID_HOME before anything else in the path it fixed the issue, and they filed a bug to prioritize $ANDROID_HOME in a future build.
Im trying to use calabash and android for testing. So it is just a started and installed calabash. The problem comes when I try to execute the first test when I run:
calabash-android run myAPP.apk
I get a response:
`raise_if_android_home_not_set': Please set the ANDROID_HOME environment variable (RuntimeError)
How do I setup ANDROID_HOME?
Where do I setup ANDROID_HOME?
From your experience, do you recommend calabash?
Thanks
Before the calabash-android run command:
From the terminal just run: export ANDROID_HOME=/Applications/adt-bundle-mac-x86_64/sdk
Were you replace the path with the path of your sdk
Edit your ~/.profile file and add in the line:
export ANDROID_HOME=PATH_TO_WHERE_SDK_INSTALLED
Where PATH_TO_WHERE_SDK_INSTALLED is replaced by the actual path to android sdk.
export PATH=$PATH:/opt/ActiveTcl-8.5/bin
Restart the shell for the changes to take effect or source it, i.e.:
source .bashrc
See my blog for more information on getting Calabash set up: whitneytaylorimura.wordpress.com