cordova error ENOENT - android

I'm trying to add android platform using cordova but i'm getting that error.
I have problem adding wp7, wp8 and windows 8 as shown below:
I tried a few things found here Phonegap Build android - error "Adding the android platform" ENOENT but doesnt help me. Anyone have any idea how to solve this??

If after type android in cmd says: 'xcopy' was not recognized.
then add to your path: %SystemRoot%\system32; %SystemRoot%; %SystemRoot%\System32\Wbem;
After 3 days trying to solve the same issue, finally I found the solution. Thank's to:
Installing Phonegap on Windows 7 : The command 'android' failed
(I can't add comments yet)

Download and install node.js
http://nodejs.org/
Install ant using brew and set ANDROID_HOME to your path.
Download and install Homebrew by executing following command in terminal:
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
Install Apache Ant via Homebrew by executing
brew install ant
set ANDROID_HOME to your path
%ANDROID_HOME%;

Related

Building Ionic app on UBUNTU for Android fails with exit code 2: Failed to find 'ANDROID_HOME'

I am using Ubuntu 14.04 version and im trying to work with ionic.
The error comes when I try to:
$ ionic start todo blank
$ cd todo
$ sudo ionic platform add android
$ sudo ionic build android
And 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.]
ERROR building one of the platforms: Error: /home/kelvin/Desktop/todo/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/kelvin/Desktop/todo/platforms/android/cordova/build: Command failed with exit code 2
I know there is alot of sites with a answer to this question, but none of them gave me a fix. Or maybe they did, but I didnt understand it. I tried on this site building-ionic-app, but that didnt work either.
I followed this tutorial by Nic Raboy, and its still not working.
Install Android, Cordova, and Ionic Framework in Ubuntu.
So let me explain what I did and maybe that is helpfull to fix my problem:
I started with this guide: Ionic Framework Guide
To install Cordova, make sure you have Node.js installed, then run
Install Node.js
$ sudo apt-get install -y nodejs
$ node -v
v5.0.0
Install Cordova
$ sudo npm install -g cordova
Follow the Cordova platform guides for Android and iOS to make sure you have everything needed for development on those platforms.
Follow the Cordova platform guides for Android
I followed this guilde:
Complete installing guide for android SDK / ADT Bund on Ubuntu
My computer is 64-bit and since im using 14.04.
Step 2: install libgl1-mesa-dev:i386 package.
$ sudo apt-get install libgl1-mesa-dev:i386
Step 3: Install openjdk-6-jdk or better, openjdk-7-jdk
$ sudo apt-get install openjdk-7-jdk
Step 4: Download the Android SDK or the ADT Bundle from here and unzip it to wherever you want.
Then I follow step 4 on techtach Complete Guide
$ wget http://dl.google.com/android/android-sdk_r20-linux.tgz
$ wget http://dl.google.com/android/adt/22.6.2/adt-bundle-linux-x86_64-20140321.zip
Then I unzipped the adt-bundle and copied the folders from SDK -> /home/kelvin/android-sdk-linux/
The folders are: build-tools,extras,platforms,platform-tools,system-images,tools.
Then I executed the following command to install latest android updates
$cd ~/android-sdk-linux/tools
$sudo ./android
And installed
Android SDK Tools (24.0.2)
Android SDK Platform-tools (20)
ANDROID SDK Build-tools (19.0.3)
SDK Platform
ARM EABI V7a System Image
Android Support Library
And then open bashrc
$gedit ~/.bashrc
And added the following lines.
export PATH=${PATH}:~/android-sdk-linux/tools
export PATH=${PATH}:~/android-sdk-linux/platform-tools
export ANDROID_HOME=~/android-sdk-linux/tools
Checking if it is right:
$ANDROID_HOME
bash: /home/kelvin/android-sdk-linux/tools: Is a directory
Create the project & Configure Platforms
$ ionic start todo blank
$ cd todo
$ sudo ionic platform add android
$ sudo ionic build android
And 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.]
ERROR building one of the platforms: Error: /home/kelvin/Desktop/todo/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/kelvin/Desktop/todo/platforms/android/cordova/build: Command failed with exit code 2
And now im kinda lost. I found a forum where they have the same problem: ANDROID_HOME is not set... and one of the guys suggested.
I finally solved it. It was on my users path but not the root users path. I have to run these commands as a root user. I had to edit my root users .bash_profile file.
and one of the others tells how:
In Ubuntu, do all the commands also root
sudo su
gedit ~/.bash_profile
export ANDROID_HOME=/root/Android/Sdk
export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
But a third guy said this is a bad idea, so I didnt do it.
I can run the following command:
$ionic serve
And it runs in the browser, but I cant run for android.
I just read your question and it seems you followed the correct way.I faced the same situation during installation process.
The proper set up an Ubuntu machine for Ionic Framework Android development has many steps.Now there are a ton of options to handle this task, but not many bare bones solutions. Most solutions on the internet explain how to use an IDE, or fail to elaborate a complete installation.
After a research,I have found a nice tutorial by Nic Raboy.I followed this tutorial and everything is fine now.
Install Android, Cordova, and Ionic Framework in Ubuntu

Cordova error while adding android in mac

I'm working on a macbook and developing with cordova. Now, I want to create an Android apk, but, when I type cordova platform add android I get this:
Error: The command "android" failed. Make sure you have the latest Android SDK installed, and the "android" command (inside the tools/ folder) is added to your path.
Ok, this message should be very clear about what to do next, but don't know what to do. When I search I keep getting how to solve this in Windows and can't follow steps.
What (and how) should I do?
Thanks
EDIT:
I've already installed Android SDK when trying to compile apk.
More info:
As I couldn't install ANT, I uninstalled it: brew uninstall ant. But when brew install antagain I got:
$ brew install ant
==> Downloading http://www.apache.org/dyn/closer.cgi?path=ant/binaries/apache-ant-1.9.3-bin.tar.gz
==> Best Mirror http://apache.rediris.es/ant/binaries/apache-ant-1.9.3-bin.tar.gz
curl: (22) The requested URL returned error: 404 Not Found
Error: Failed to download resource "ant"
Download failed: http://apache.rediris.es/ant/binaries/apache-ant-1.9.3-bin.tar.gz
Some things to make sure you have completed before starting w/ Android:
Make sure ANT is installed:
Try ant --version, if command not found you need to install ANT.
The easiest way I have found is to use Homebrew. If you do not have homebrew installed, get it here
Once installed run
homebrew update
homebrew install ant
Unpack Android SDK:
Download and unpack the SDK package, place it in an easy to find location.
Then add the tools and platform-tools paths to your global PATH, like this:
vi ~/.bash_profile
add this line:
export PATH=/path/to/android/sdk/tools:/path/to/adnroid/sdk/platform-tools:$PATH
Exit the terminal and re open the terminal.
Now you should be able to run cordova platform add android in your project folder.

Cordova Plugins Installation MAC

I am using Cordova 3.3.0 and I want to install the camera and network plugins. In netbeans it is very simple to do so but I can't understand how this can be accomplished on MAC. Please note that I am very new to this.
I am trying to run the following command in the terminal:
cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-camera.git
An error is saying
-bash: cordova: command not found
Can anyone guide me what needs to be done?
Thanks
If Cordova is well installed on your Mac, you need to add "/usr/local/share/npm/bin" directory to your $PATH variable. Open your Terminal / Command line and type:
export PATH=$PATH:/usr/local/share/npm/bin
Else, before install Cordova typing :
npm install -g cordova

PhoneGap/Cordova Android Development

UPDATE 1:
This was everything I did in the end:
sudo aptitude install -y python-software-properties python g++ make
sudo add-apt-repository -y ppa:chris-lea/node.js
sudo aptitude update
sudo aptitude install nodejs
sudo aptitude install npm
sudo npm install -g cordova
sudo npm install -g phonegap
phonegap create my-app
cd my-app
export PATH=${PATH}:/home/oshirowanen/Downloads/adt-bundle-linux-x86_64-20131030/sdk/platform-tools:/home/oshirowanen/Downloads/adt-bundle-linux-x86_64-20131030/sdk/tools
sudo aptitude install ant
cordova platform add android
android create avd --name my_and --target 1
phonegap run android
Was any of that not neccessary?
ORIGINAL QUESTION:
On my Ubuntu 12.04 computer, I've just installed node.js with npm and cordova:
$ node -v
v0.10.23
$ npm -v
1.3.17
$ cordova -v
3.3.0-0.1.1
When I try to add android:
$ cordova platform add android
I get the following output:
Creating android project...
/usr/lib/node_modules/cordova/node_modules/q/q.js:126
throw e;
^
Error: An error occured during creation of android sub-project.
/home/oshirowanen/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:126
throw e;
^
Error: An error occurred while listing Android targets
at /home/oshirowanen/.cordova/lib/android/cordova/3.3.0/bin/lib/check_reqs.js:87:29
at _rejected (/home/oshirowanen/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:808:24)
at /home/oshirowanen/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:834:30
at Promise.when (/home/oshirowanen/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/home/oshirowanen/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:752:41)
at /home/oshirowanen/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:574:44
at flush (/home/oshirowanen/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
at /usr/lib/node_modules/cordova/src/platform.js:244:30
at ChildProcess.exithandler (child_process.js:641:7)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:735:16)
at Socket.<anonymous> (child_process.js:948:11)
at Socket.EventEmitter.emit (events.js:95:17)
at Pipe.close (net.js:466:12)
Anyone know why this is happening and how to resolve it?
I get the same issue with PhoneGap.
It's possible that the Android tools binaries are not in your path.
According to the PhoneGap docs (http://docs.phonegap.com/en/2.9.0/guide_getting-started_android_index.md.html), you need to include the Android SDK's tools and platform-tools in your PATH environment variable.
export PATH=${PATH}:/Development/adt-bundle/sdk/platform-tools:/Development/adt-bundle/sdk/tools
where Development is the path you installed your SDK.
Run the "android" command from your adt\sdk\tools folder and install the latest Tools and SDK. Also make sure your PATH has the right variables.
For this you will need ANT to be installed , a JAVA JDK and an Android SDK installed
JAVA_HOME (C:\Program Files\Java\jdk)
ANT_HOME ({ant location}\apache\apache-ant)
ANDROID_HOME ({android sdk location}\android-sdk)
Add these to your PATH variable like %ANT_HOME%/bin;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools;%JAVA_HOME%\bin
Close and re-open your cmd and run your command again.
I'm running Ubuntu 12.04 and was having the same problem as you until a few minutes ago.
The two things I've noted that I had missed during installation:
The Android version should be 19 and you should be able to type 'android' at the console and see some output or see a window pop-up. Make sure that you add the path to the folder where android.jar is located to your PATH variable, and set ANDROID_HOME to that same path as well. Typically, you would do this in your .bashrc file or in /etc/environment If you edit either of these files, you'll need to either 'source ~/.bashrc' or reopen your terminal to force it to reload the file. Type 'android' to make sure its working.
I observed that the cordova setup script was attempting to write files into a subdirectory 'add-ons' of the Android SDK. That directory does not exist in the Android 19 distribution itself. Consequently, I created it manually and made it writeable by my user account.
ex: Android distribution path:
/opt/android/
The path that its trying to write to:
/opt/android/sdk/add-ons
Once I had done that I was able to get past the problem you've noted above.
It looks like the cordova andorid library file corrupted in your home directory.
Try to remove home//.cordova directory and do this again cordova platform add android in your cordova project.
Make sure you have sourced /platform-tools and /tools to PATH.
Android
The Android command-line tools are built upon shell scripts. You must have the Android SDK's tools and platform-tools folders in your PATH!
Create a project
Run the create command with the following parameters:
Path to your new Cordova Android project
Package name, following reverse-domain style convention
Main Activity name
$ /path/to/cordova-android/bin/create /path/to/my_new_cordova_project com.example.cordova_project_name CordovaProjectName
It looks like this error could also be caused by the absence of a compatible Android SDK version (at the moment 4.2).
I use cordova.
2days I have same problem"java,ant,android,cordova,command test is ok,
but run cordova platform add android show me Error: An error occurred while listing Android targets".
Now I fixit use:
"chmod 777 ant and android sdk place"
,then it will work.
I use ubuntu 14.04 32bit,
if the problem still exist please make sure that you have the right permissions try
sudo chmo-R 777 /home/your-user-name/.cordova/
Also make sure that you are NOT using sudo to add Android as a platform
This is incorrect in the default Cordova installation
sudo cordova platform add android
Just do
cordova platform add android
I've searched a lot for this, and what worked for me was setting the shell variable $ANDROID_HOME to the path of the sdk/ folder in my adt-bundle directory from android. Use export to do this:
export ANDROID_HOME="/Users/YOUR_USER/Developer/adt-bundle/sdk/"
but be sure to change the directory to match yours.
Good Luck!
Not sure if someone else had a problem with this, but when removed and added my platform again, I realized in my config.xml I had <icon src='...'> and the path inside the src was wrong.
Here was the error output I received when I added the platform again:cp: no such file or directory: C:\Users\{pathtofile}.png.
After I fixed the path, it worked fine.
It can be that your cordova installation have been corrupted try to remove your .cordova folder "rm -R ~/.cordova"
And "run cordova platform add android" again

Error executing command 'ant' on Mac OS X 10.9 Mavericks when building for Android with PhoneGap/Cordova

Today I tried PhoneGap/Cordova with Mac OS X Mavericks. Building for iOS went just fine, but building for Android wasn't without some guesswork.
I installed Android 4.2.2 via the Android SDK Manager (I had to use the older API v17 since it wasn't compatible with a newer one), added the PATH environment variables for the SDK's platform-tools and tools and thought I was ready to take off by running the command:
phonegap run android
Nevertheless, I got the following error:
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] adding the Android platform...
[error] An error occured during creation of android sub-project. ERROR : executing command 'ant', make sure you have ant installed and added to your path.
The error message proved to be true as Apache Ant isn't in the path of Mac OS X Mavericks anymore.
Bulletproof solution:
Download and install Homebrew by executing following command in terminal:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Install Apache Ant via Homebrew by executing
brew install ant
Run the PhoneGap build again and it should successfully compile and install your Android app.
You can install ANT through macports or homebrew.
But if you want to do without 3rd party package managers, the problem can simply be fixed by downloading the binary release from the apache ANT web site and adding the binary to your system PATH.
For example, on Mountain Lion, in ~/.bash_profile and ~/.bashrc my path was setup like this:
export ANT_HOME="/usr/share/ant"
export PATH=$PATH:$ANT_HOME/bin
So after uncompressing apache-ant-1.9.2-bin.tar.bz2 I moved the resulting directory to /usr/share/ and renamed it ant.
Simple as that, the issue is fixed.
Note Don't forget to sudo chown -R root:wheel /usr/share/ant
As an alternative to homebrew, you could download and install macports. Once you have macports, you can use:
sudo port install apache-ant
it don't needed port and brew!
because you have android sdk package.
.1 edit your .bash_profile
export ANT_HOME="[your android_sdk_path/eclipse/plugins/org.apache.ant_1.8.3.v201301120609]"
// its only my org.apache.ant version, check your org.apache.ant version
export PATH=$PATH:$ANT_HOME/bin
.2 make ant command that can executed
chmod 770 [your ANT_HOME/bin/ant]
.3 test if you see below message. that's success!
command line execute: ant
Buildfile: build.xml does not exist!
Build failed
I encountered the same issue when trying to use Cordova. Turns out I already had brew, try which brew, but it was outdated. So, I had to update it first:
Update brew: brew update
Install Apache Ant: brew install ant
In my case, I have macport installed already. I simply updated my macport:
sudo port selfupdate
sudo port upgrade outdated
Then install apache-ant:
sudo port install apache-ant
Finally, I add ant to my alias list in my .bash_profile:
alias ant='/opt/local/bin/ant'
Then you are all set.
For OSX your path needs to include /Users/yourusername
their example: /Development/adt-bundle/sdk/platform-tools
needs to be: /Users/yourusername/Development/adt-bundle/sdk/platform-tools

Categories

Resources