Phonegap 3 doesn't work with Android Studio - android

It seems rather simple to me, but I can't do it at all.
I have npm install -g phonegap with everything successful and installing phonegap.
I have followed instructions from here http://phonegap.com/install/ i have then created my project:
C:\var\www\sexdiaries.co.uk>phonegap create sexdiaries -n SexDiaries -i co.uk.sexdiaries.app
I have then, as told Here tried to run andriod but with the following errors
C:\var\www\sexdiaries.co.uk\sexdiaries>phonegap run andriod
C:\Users\Hutber\AppData\Roaming\npm\node_modules\phonegap\lib\phonegap\run.js:72
self.phonegap.emit('log', 'detecting', platform.human, 'SDK environment...
^
TypeError: Cannot read property 'human' of undefined
at RunCommand.execute (C:\Users\Hutber\AppData\Roaming\npm\node_modules\phonegap\lib\phonegap\run.js:72:52)
at RunCommand.run (C:\Users\Hutber\AppData\Roaming\npm\node_modules\phonegap\lib\phonegap\run.js:55:10)
at PhoneGap.run (C:\Users\Hutber\AppData\Roaming\npm\node_modules\phonegap\lib\phonegap\util\command.js:28:25)
at CLI.module.exports [as run] (C:\Users\Hutber\AppData\Roaming\npm\node_modules\phonegap\lib\cli\run.js:38:14)
at CLI.module.exports [as argv] (C:\Users\Hutber\AppData\Roaming\npm\node_modules\phonegap\lib\cli\argv.js:66:17)
at Object.<anonymous> (C:\Users\Hutber\AppData\Roaming\npm\node_modules\phonegap\bin\phonegap.js:24:21)
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)
More over, I have imported the project created into Andriod Studio, but when doing so I get: Source files for your project not found
I know how to create a working project using phonegap 2.9. But can't work out what 3 is offering?
So the question, how do I actually get a working local android app working using phoengap 3

The command is 'phonegap run android', It is not 'phonegap run andriod'.
Try it again. I had this problem like you.

I have used phonegap 3.0 with Android Studio and its working fine.
Please go through this

Upon must digging I found how to get past this:
phonegap run android
Its as simple as that.
[Edit]
You need to add platform to work with, whilst the documentation is so very very poor:
C:\var\www\sexdiaries.co.uk\sexdiaries>phonegap build android
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] adding the Android platform...
[warning] missing library cordova/android/3.0.0
[phonegap] downloading https://git-wip-us.apache.org/repos/asf?p=cordova-android.git;a=snapshot;h=3.0.0;sf=tgz...
[phonegap] compiling Android...
[phonegap] successfully compiled Android app
Then you are good to go, doing an import with Andriod Studio will also work now as you have a project to work with :)
Fantastic.

Related

Ionic with visual studio always give node.js not installed. Even when I am using Node.js (6.7.0). Which runs android from Node command prompt

Ionic with visual studio always give node.js not installed. Even when I am using Node.js (6.7.0). Which runs android from Node command prompt.
I want to add Windows platform to my ionic.
Typically, when you add windows as a platform in your ionic project and then build it, it creates a visual studio project in the directory which you can easily open by just clicking on it. At what stage are you getting this error and what is the exact error that you are getting?

Phone - How to do setup to create phonegap application

I followed lot of links but not able to run my application.
Steps I followed
Installed node.js.
downloaded eclipse juno.
Installed ADK plugin with https://dl-ssl.google.com/android/eclipse/.
Installed platforms and other thing mentioned in below pictures.
I installed phongap by using npm install -g phonegap command.
I am trying to create a new phonegap app by phonegap create my-app but its giving error
Error: Cannot find module 'cordova-common'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:289:25)
at Module.require (module.js:366:17)
at require (module.js:385:17)
The way I followed is correct or not? Please give me any link to create new phonegap application from setting required sertup.
Thank you.
try to update Cordova's version to the latest version:
CLI:
sudo npm update -g cordova
It fixed my issue with adding/building ios platform (same error)

Phonegap 3.4 doesn't copy android to platforms folder (ubuntu 12)

I have seen different flavours of this question being discussed in the forum.
Excuse me for re-posting it because I have tried all the options discussed without any luck :(
My Env
OS : ubuntu 12
Phonegap : 3.4
Android SDK : 19
Have installed cordova separately as well
Steps I have followed
1)Created project using phonegap create command
shaiju#shaiju:~/workspace/adt$ phonegap create HelloWorld
[phonegap] created project at /home/shaiju/workspace/adt/HelloWorld
2)Changed to directory HelloWorld
shaiju#shaiju:~/workspace/adt$ cd HelloWorld/
shaiju#shaiju:~/workspace/adt/HelloWorld$
3) build using phonegap build command for android
shaiju#shaiju:~/workspace/adt/HelloWorld$ phonegap build android
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] adding the Android platform...
No error thrown , but the platform folder is empty. Nothing has created there :(
I have tried similar steps using cordova command as well to get the same result
Also tried running the step 3 above with "local" keyword to force the local build. Same result :(
What am I missing here ?
Do we have a bug in phonegap 3.4 on ubuntu?
Thanks in advance
Shaiju

Installing PhoneGap Cordova 3.0

I was using phonegap 2.9 for development, it was pretty easy installing that but, phonegap 3.0 uses some nodejs and command line for installation. I found this tutorial but I am stuck at one step. untill this line,
npm install -g plugman.
it is working, but after this step there is a line,
Then change to the working directory to the project directory.
I can't figure this out and getting an error when i run
cordova -d platform add android
This is the error i am facing,
C:\Users\Comp\AppData\Roaming\npm\node_modules\cordova\src\util.js:57
throw new Error('Current working directory is not a Cordova-based
^
Error: Current working directory is not a Cordova-based project.
at Object.module.exports.cdProjectRoot (C:\Users\Comp\AppData\Roaming\npm\no
de_modules\cordova\src\util.js:57:19)
at CLI.platform (C:\Users\Comp\AppData\Roaming\npm\node_modules\cordova\src\
platform.js:35:36)
at new CLI (C:\Users\Comp\AppData\Roaming\npm\node_modules\cordova\src\cli.j
s:109:30)
at Object.<anonymous> (C:\Users\Comp\AppData\Roaming\npm\node_modules\cordov
a\bin\cordova:41:16)
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)
Any help would be appreciated.
I think you haven't created a new project with:
cordova create [PATH] [ID] [NAME]
This will create a
.cordova, platform and www folder.
Things are a bit different when you use 3.3, you won't have a .cordova folder in that case but that doesn't really matter.
After running the create command you should add the android platform (after cd-ing into the path you entered with the cordova create command) with "cordova platform add android".
Now you should copy the contents of your 2.9 app www folder to the www folder Cordova created.
After running "cordova build android" you will notice that it copied the www folder to "platforms/android/assests/www", you should never change things here because running the cordova build android command will overwrite it.
More info on the following page: http://cordova.apache.org/docs/en/3.2.0/guide_platforms_android_upgrading.md.html#Upgrading%20Android

Why does my phonegap build android command not work?

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

Categories

Resources