Build not found in Phonegap 3.0 for android - android

I have installed Cordova along with Phonegap and installed node.js in my system(ubuntu)
by using following commands:
Install Nodejs http://nodejs.org/
Install Cordova 3.0.x
$ sudo npm install -g cordova
Install Phone Gap 3.0.x
$ sudo npm install -g phonegap
Then i created project using phonegap command:
$ phonegap create hello
Trying to run into my local by using following command:
$ phonegap local run andriod
Now at first i am getting following error:
shoaib#shoaib:~/Documents/hello$ phonegap local run android
[phonegap] adding the Android platform...
[error] An error occured during creation of android sub-project. /home/shoaib/.cordova/lib/android/cordova/3.0.0/bin/create: line 54: jar: command not found
This i solved by running following command:
ls -la /home/shoaib/.cordova/lib/android/cordova/3.0.0/bin
Now when i again run
$ phonegap local run andriod
I am getting below error:
root#shoaib:/home/shoaib/Documents/hello# phonegap local run android
[phonegap] compiling Android...
[error] An error occurred while building the android project. /bin/sh: 1: /home/shoaib/Documents/hello/platforms/android/cordova/build: not found
I am using Android SDK 17
and version as 4.2.2 .
Any solution for this issue?

I had a similar problem. build and run were missing along with a few other files and lib was an empty directory. Downloaded cordova-android from here extracted and copied everything from its /bin/templates/cordova/ to the project (/platforms/android/cordova/). Then I could build and install the app.
Still had to start the emulator, check the running emulator with platforms/android/cordova/lib/list-started-emulators and then pass it when installing or it would take forever to install it on an emulator.
$ platforms/android/cordova/lib/list-started-emulators
emulator-5554
$ phonegap install --emulator=emulator-5554 android

I had already installed the JDK but the same error.
To fix this I just removed the phone test project and make sure that:
Java, javac and jar where in the path
(both should work)
java -version
javac -version
jar -version
Android sdk path was properly set and JAVA_HOME environment variable was properly set.
Then I remake the project and everything worked.

Hey got the solution.
I install open jdk 6.0 and problem is resolved.

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

Can't execute ionic application in genymotion

I try to execute an application implemented using Ionic within the Genymotion Android emulator.
To create my application, I did the following:
$ ionic start myApp blank
$ ionic platform android
$ ionic run android
Notice that I executed the last command after having started a virtual terminal (Sony Xperia Z for example).
I have the following error:
Running command: /(...)/myApp/hooks/after_prepare/010_add_platform_class.js /(...)/myApp
add to body class: platform-android
Running command: /(...)/myApp/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: /(...)/myApp/platforms/android/cordova/build: Command failed with exit code 2
You may not have the required environment or OS to build this project
Error: /(...)/myApp/platforms/android/cordova/build: Command failed with exit code 2
I don't understand why I need to have an ANDROID_HOME set since it's not the thing I want to use...
I installed then an Android SDK and set the ANDROID_HOME environment variable:
export ANDROID_HOME=/home/(...)/android-sdk-linux/
Then I have the following error:
$ ionic run android
Running command: /(...)/myApp/hooks/after_prepare/010_add_platform_class.js /(...)/myApp
add to body class: platform-android
Running command: /(...)/myApp/platforms/android/cordova/run
ERROR: Error: Please install Android target: "android-22".
Hint: Open the SDK manager by running: /home/(...)/android-sdk-linux/tools/android
You will require:
1. "SDK Platform" for android-22
2. "Android SDK Platform-tools (latest)
3. "Android SDK Build-tools" (latest)
ERROR running one or more of the platforms: Error: /(...)/myApp/platforms/android/cordova/run: Command failed with exit code 2
You may not have the required environment or OS to run this project
What isn't clear to me is how to tell Cordova to use Genymotion instead of the default Android emulator...
For information, I installed ionic and cordava like this:
$ sudo npm install ionic -g
$ sudo npm install cordova -g
I'm working on Linux Mint 17 Qiana / Cinnamon 64-bit.
Thanks very much in advance for your help!
Thierry
From the logs it doesn't look like a problem with the emulator/Genymotion but a problem with not having the Android SDK installed. Because of the licenses involved you typically need to install the Android SDK yourself.
This explains the error messages:
It first looks for where the SDK is installed, which is indicated by ANDROID_HOME. It errors since it's initially unset.
Once it's set, it can't find the right SDKs (android-22, platform-tools, tools) since they're not installed.

phonegap run android - create Command failed with exit code 8 - linux

I did some googleing but find nothing approriate.
Any help appreciated. Try it with an naked vm to be sure
having no nodejs install or dependency issue.
Christian
sudo apt-get install nodejs
sudo apt-get install nodejs-legacy
sudo npm install -g phonegap
sudo npm install -g cordova
sudo apt-get install ant
chris#mint16 ~/project/dev $ phonegap create my-app
[phonegap] create called with the options /home/chris/project/dev/my-app com.phonegap.helloworld HelloWorld
[phonegap] Customizing default config.xml file
[phonegap] created project at /home/chris/project/dev/my-app
chris#mint16 ~/project/dev $ cd my-app/
chris#mint16 ~/project/dev/my-app $ phonegap run android
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] adding the Android platform...
/home/chris/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:126
throw e;
^
Error: An error occurred while listing Android targets
at /home/chris/.cordova/lib/android/cordova/3.5.0/bin/lib/check_reqs.js:87:29
at _rejected (/home/chris/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:808:24)
at /home/chris/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:834:30
at Promise.when (/home/chris/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/home/chris/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:752:41)
at /home/chris/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:574:44
at flush (/home/chris/.cordova/lib/android/cordova/3.5.0/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
{ [Error: /home/chris/.cordova/lib/android/cordova/3.5.0/bin/create: Command failed with exit code 8] code: 8 }
[error] /home/chris/.cordova/lib/android/cordova/3.5.0/bin/create: Command failed with exit code 8
I've just faced the same issue, the problem was that path to sdk tools was not properly setup:
So try the following:
export PATH=$PATH:/usr/local/adt-bundle/sdk/tools
export PATH=$PATH:/usr/local/adt-bundle/sdk/platform-tools
export PATH=$PATH:/usr/local/adt-bundle/sdk/build-tools
I also hit the same issue, but just adding the various android sdk tools directories to the path as DKMudrechenko suggested above did not help. It turned out that I had not installed ant properly. I had downloaded it from apache.org and just added the ant 'bin' folder to my path, but apparently that wasn't good enough. However, after removing that entry from my path statement and adding ant via brew, I was then able to build the android cordova project successfully using the 'cordova build android' command.
i have been facing this issue on and off only to realise that the build fails for other errors in the code/configuration.
the process you have taken does skip one part where the android platform is added
corodova platforms add android
in the steps given above, you have created a project, traversed into the project directory and then ran the build, to which the phone gap checked the installed sdks by checking ANDROID_HOME and tried to set up the project for android.
you might want to run it in a correct order:
create project
move to the project directory
add platform
build / run.
i hope this helps

Error in add android to cordova/phonegap project

I,m unable to add android platform support to phonegap/cordova project.
when I run following command on CLI :
cordova platforms add android
it's giving this error :
Error: ERROR : executing command 'ant' , make sure you have ant installed and added to your path
you need to clean up your eclipse
cd to your eclipse directory and run this command
./eclipse -clean
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
Build project
cordova build android

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