Domanda

I want to write an HTML5 app to activate the user's camera to read a barcode.

I don't know what the difference is between PhoneGap and Cordova so I'm really confused. I'm probably installing way too much software on my PC, but I'm just trying to follow directions and hopefully at some point will be able to start writing some JavaScript.

I installed npm on my Windows 8 machine. When I type "phonegap run android" is says

[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] adding the Android platform...
[phonegap] missing library cordova/android/3.3.0
[phonegap] downloading https://git-wip-us.apache.org/repos/asf?p=cordova-android
.git;a=snapshot;h=3.3.0;sf=tgz...
   [error] An error occured during creation of android sub-project.

C:\Users\Phillip\.cordova\lib\android\cordova\3.3.0\bin\node_modules\q\q.js:126
                    throw e;
                          ^
Error: ERROR : executing command 'ant', make sure you have ant installed and add
ed to your path.
    at C:\Users\Phillip\.cordova\lib\android\cordova\3.3.0\bin\lib\check_reqs.js
:47:27
    at ChildProcess.exithandler (child_process.js:641:7)
    at ChildProcess.EventEmitter.emit (events.js:98:17)
    at maybeClose (child_process.js:743:16)
    at Socket.<anonymous> (child_process.js:956:11)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Pipe.close (net.js:466:12)

I then downloaded ant and extracted it to c:\apache-ant. I then added user variables ANT_HOME with a value of c:\apache-ant. I also added ;C:\apache-ant\bin to the system variable "path".

When I drop to the cmd line, and type "cordova" is says that cordova is not recognized.

Edit 1: typing "phonegap run android" yields:

[error] project directory could not be found

Edit 2:

Maybe I should just download cordova.js from their download page. I'd be happy to have it work for only the iPhone at first.

È stato utile?

Soluzione

I would recommend using PhoneGap Build. PhoneGap Build can be found at:

PhoneGap Build

If you use that then you can scan the app directly with your android device, with a bar code reader. The app will automatically download to your device and you can run the app there.

You can also use another program called BlueStackes. Link:

BlueStacks

BlueStacks is an emulator.

Altri suggerimenti

cordova is a framework aimed to package (heavily adapted) webapps (conceived for the local device webview) in a mobile device friendly package along with a system specific compiled library(es) who expose system api to webview. Cordova is also the nodejs command name used in the app build workflow (Cordova CLI, command line interface).

Phonegap is a cordova framework distro from Adobe and the corresponding nodejs command (phonegap CLI). The most important phonegap addition to cordova is the possibility to pass your project to the adobe proprietary building service Phonegap Build who work outofthebox for every supported target device.

the two command (cordova and phonegap) are slightly differents: all of cordova functions are in phonegap, who internally calls cordova, and phonegap add some more, and slightly change it's syntax (refers to cordova CLI docs and phonegap CLI docs for differences).

the framework's toolschain is a little complex. to have a working cordova\phonegap env you need, in order:

  • node.js
  • git
  • plugman (via node -g)
  • phonegap (via node -g)
  • cordova (via node -g)
  • ant
  • [yourplatform] developement kit (i.e. ADK android developement kit) and his dependancies

another confusing feature starting from phonegap/cordova3.x is that almost every core API is now packaged as cordova's external plugin. That means that for a real word working app you almost for sure need to add to your toolchain some of these, which is (normally) easily do via cordova CLI option plugin add <pluginRepositoryAddress>.

Barcode api are in a third party plugin who can be added to your project in the same way.

You can google all of these info and setup your environement correctly.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top