I have a phonegap created for iOS, and I want to build it for Android, but the following commands would not convert it to an Android project:
phonegap platform update android
phonegap install android
phonegap build android
Here is one of the errors that I receive:
lucas#lucas-ThinkPad-W520:~/projects/ecostartup/ecometrix-app$ phonegap platform update android
[phonegap] updating Android platform...
[error] Platform "android" is not installed.
lucas#lucas-ThinkPad-W520:~/projects/ecostartup/ecometrix-app$ phonegap install android
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] trying to install app onto device
[phonegap] no device was found
[phonegap] trying to install app onto emulator
[error] The provided path "/home/lucas/Dropbox/projects/ecostartup/ecometrix-app/platforms/android" is not an Android project.
Here is another error:
lucas#lucas-ThinkPad-W520:~/projects/ecostartup/ecometrix-app$ phonegap build android
[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.
/home/lucas/.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/lucas/.cordova/lib/android/cordova/3.3.0/bin/lib/check_reqs.js:87:29
at _rejected (/home/lucas/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:808:24)
at /home/lucas/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:834:30
at Promise.when (/home/lucas/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/home/lucas/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:752:41)
at /home/lucas/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:574:44
at flush (/home/lucas/.cordova/lib/android/cordova/3.3.0/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
lucas#lucas-ThinkPad-W520:~/projects/ecostartup/ecometrix-app$
And here is some project info:
lucas#lucas-ThinkPad-W520:~/projects/ecostartup/ecometrix-app$ ls
platforms plugins README.md www
lucas#lucas-ThinkPad-W520:~/projects/ecostartup/ecometrix-app$ ls platforms/
ios
How can I convert this to Android?
actually looking at your logs, it seems that the app has been built. The only visible error is that no phone was detected and the emulator could not be started.
About the commands you use :
phonegap platform update android this one is for when you already added android platform to your project and installed a newer version of phonegap so you don't need it for the moment
phonegap install android here you're trying to install your app to a device connected to your computer with proper drivers installed and debuging allowed
phonegap build android here you go, this is the good command to build the android project and generate a debug apk.
Once you run build, you should find the debug apk in platforms/android/bin
If you use some plugins, also check that they are compatible with android.
I double checked to make sure that Android was on my path:
lucas#lucas-ThinkPad-W520:~/projects/ecostartup/ecometrix-app/platforms$ echo $PATH
(rest of path)...:/opt/android-sdk-linux/sdk/tools:/opt/android-sdk-linux/sdk/platform-tools
But I needed to install Cordova:
sudo npm install -g cordova
and I ran phonegap build android, which gave me another error to install Ant:
sudo apt-get install ant
This was all after installing nodejs, npm, and phonegap.
I found this post very helpful:
PhoneGap/Cordova Android Development
(it just took me a while to find it)
Related
I installed latest version of phonegap with npm, which shows version 4, and latest android sdk.
After creating simple myApp "hello world" project to test, I added android platform and can do local build and run the app with phonegap developer app on my phone.
But... if I do a remote phonegap build then the error log from build.phonegap.com for this app shows
'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.'
I have JAVA_HOME and ANT_HOME configured and ant and the android sdk tools and platform-tools are in my path.
I can execute android from cmd shell to bring up SDK Manager.
This is all on Windows 7 64 bit.
I'm probably missing something simple, but driving me nuts that I can't do a remote build.
It appears that there was a temporary problem with the phonegap build service, which is now working again.
Ah well...
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.
I am trying to create a simple project in phonegap with association of wikitude.
This is the tutorial which I followed - wikitude + phonegap tutorial
And I am using ubuntu 12.04 these are the only steps which I followed,
$ npm install -g phonegap - Adding phonegap
npm install plugman - Adding plugman
sudo npm install -g cordova - installing codova
Then following steps to create app,
$ phonegap create MyAugmented - create app
$ phonegap build android - build in android
Aditionally I have installed android sdk using apt-get.
But when I build this app using above build command it gives an error,
Error in Text :
Error: An error occurred while listing Android targets
at /home/sachith/.cordova/lib/android/cordova/3.4.0/bin/lib/check_reqs.js:87:29
at _rejected (/home/sachith/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:808:24)
at /home/sachith/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:834:30
at Promise.when (/home/sachith/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:1079:31)
at Promise.promise.promiseDispatch (/home/sachith/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:752:41)
at /home/sachith/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:574:44
at flush (/home/sachith/.cordova/lib/android/cordova/3.4.0/bin/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:415:13)
{ [Error: /home/sachith/.cordova/lib/android/cordova/3.4.0/bin/create: Command failed with exit code 8] code: 8 }
[error] /home/sachith/.cordova/lib/android/cordova/3.4.0/bin/create: Command failed with exit code 8
Answers would be really appreciated,
Thanks in Advanced.
Most probable reason is you don't have latest android SDK. So update your android SDK and it should work fine.
You can reference this to see way of finding error.
Cordova has a script to check if all dependencies are present. Is is
called when you run cordova platform add android but unfortunatly it's
output is not displayed when it fails.
You can try to run it manually, it should be
$home/.cordova/lib/android/cordova/3.3.0/bin/check_reqs
The normal output when everything's fine is "Looks like your
environment fully supports cordova-android development!", oterwise it
should display a clear message about what's missing.
Maybe your issue is that you havent't installed SDK platform for API
19 in android sdk manager (cordova 3.3 uses target sdk 19).
UPDATE:
Android SDKs are updated using SDK Manager. You can see how to use SDK from here.
http://developer.android.com/tools/help/sdk-manager.html
I'm trying to compile my phonegap project using the cordova cli on my Win8 machine. I've updated all my Android SDKs, updated cordova and phonegap but I cannot build my project. I get an error that the .cordova/hooks/any_hook is empty.
I looked in that directory and can't see any files in there. How do those files get there and is the latest version of cordova bad? Until now I've been compiling on my Mac because I couldn't get the PC setup correctly so today I decided to take a crack at it and have failed.
I even created a new hello world project using the CLI but still no luck in building the thing because of the supposed missing hook files. Anyone have any insight to this.?
Also, I've tried using the command prompt in both ADMIN and regular mode. Still no luck.
EDIT:
I'm using phonegap 3.3.0-4.18.0
Path to hooks:
Z:\projecttitleroot\projecttitle.cordova\hooks
OUTPUT OF PHONEGAP BUILD WITH DEBUG:
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] compiling Android...
[error] ENOENT, no such file or directory 'Z:\myprojectroot\myproject\.cordova\hooks\before_build'
I want to point out that I'm using phonegap command to compile and run, NOT cordova as per the documentation for the latest version.
If I run:
cordova -d build android
I get this:
Z:\myprojectroot\myproject>cordova -d build android
C:\Users\MYUSER\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:126
throw e;
^
Error: ENOENT, no such file or directory 'Z:\myprojectroot\myproject\.cordova\hooks\before_build' at Object.fs.readdirSync (fs.js:654:18)
at C:\Users\MYUSER\AppData\Roaming\npm\node_modules\cordova\src\hooker.js:64:34
at _fulfilled (C:\Users\MYUSER\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:798:54)
at self.promiseDispatch.done (C:\Users\MYUSER\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:827:30)
at Promise.promise.promiseDispatch (C:\Users\MYUSER\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:760:13)
at C:\Users\MYUSER\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:821:14
at flush (C:\Users\MYUSER\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:108:17)
at process._tickCallback (node.js:415:13)
at Function.Module.runMain (module.js:499:11)
at startup (node.js:119:16)
Z:\myprojectroot\myproject>
Make sure you put your hooks into subdirectories inside the hooks directory.
Path to hooks: Z:\projecttitleroot\projecttitle.cordova\hooks\before_build\
i am new to phonegap 3 and android development.
i tried the command "phonegap build android" and get:
[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.
fs.js:427
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: ENOENT, no such file or directory 'C:\Users\Michael\.cordova\lib\android\
cordova\3.1.0\VERSION'
at Object.fs.openSync (fs.js:427:18)
at Object.fs.readFileSync (fs.js:284:15)
at Object.exports.createProject (C:\Users\Michael\.cordova\lib\android\cordo
va\3.1.0\bin\lib\create.js:116:22)
at Object.<anonymous> (C:\Users\Michael\.cordova\lib\android\cordova\3.1.0\b
in\create:34:12)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
I simply add an empty file named as VERSION:
C:\Users\myuser\.cordova\lib\android\cordova\3.1.0\VERSION
after, I wrote this text inside it:
3.1.0
after, run phonegap again:
[phonegap] adding the Android platform...
[phonegap] compiling Android...
[phonegap] successfully compiled Android app
Good luck!
It is kind of tricky This is the sequence I have to go through.
run a clean in eclipse (Project Menu)
sudo phonegap build android (cordova if that is what you are using)
then you have to reapply the read write permissions to the whole folder (this step may not be needed depending on your permissions)
then in eclipse run refresh on the project
then build.
Run
I would suggest as a bare minimum first step you should check via the command line that the following commands return a response that shows they are working correctly. They are all required. Ant - http://ant.apache.org/
Java -http://www.oracle.com/technetwork/java/javaee/downloads/java-ee-sdk-6u3-jdk-7u1-downloads-523391.html
android - http://developer.android.com/sdk/index.html
In command line type the following to validate they work
Ant
java
android
Make sure you have node.js installed (http://nodejs.org/)
Also make sure you look at you PATH file and that everything is correct there.
As I say that's the basics (once you have stuff installed)
Try to install latest cordova. Maybe it will help:
$ sudo npm install -g cordova
(also you will need node.js installed)
I have removed android platform and added again.
cordova platform rm android
cordova platform add android
then,
cordova prepare android
is done without errors