I'm confused a bit by PhoneGap documentation:
I've added camera module according (1). But in (2), there is information saying that I should add
<plugin name="Capture" value="org.apache.cordova.Capture"/>
to app/res/xml/plugins.xml
and edit app/AndroidManifest.xml
files too.
In reference to 3), also there is information that <plugin ... />
construction is obsolete and the developer should use <gap:plugin ... />
, instead.
For Android you just need to replace your . jar/. js files with the 1.2 versions and update the script tag to refer to the phonegap-1.2.
Referencing the latest API documentation:
There are two ways to approach this, first is by using Plugman, and the other is by using CLI. The CLI approach is much simpler.
The Plugman approach:
First, Plugman must be installed. Plugman is the plugin manager used by PhoneGap 3.4. To install Plugman, use the Node JS CLI and enter:
npm install -g plugman
Install the specific plugin using the plugman install
command. For example plugman install --platform android --project platforms/android --plugin org.apache.cordova.device-motion
. Be sure that the parameter for the --project
option points directly to the platform folder, e.g. for Android, that's where the AndroidManifest.xml
file is. This command automatically adds all references to the plugins to the pertinent xml
files.
Be sure that your HTML
file references phonegap.js
by the line <script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
.
Using CLI:
Go to your app directory and enter the plugin command in the CLI. For example:
phonegap plugin add org.apache.cordova.device-motion
installs the accelerometer plugin.
After the plugin has installed, it automatically updates all config.xml
by adding the corresponding <feature>
tags. Note that these updates only affect the platform-specific config.xml
files. And so, the top-level config.xml
file is not affected. You must manually copy and paste the <feature>
tags to the top level config.xml
. Otherwise, the plugins will be disabled when you run the app using phonegap run platform
.
Take note that the corresponding <feature>
tags can only be added to the corresponding config.xml
files if your project is already ready to deploy in that specific platform.
If you are using phonegap 3.0 the latest as of this answer, you add plugins from the command line like so.
"phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture.git"
This is supposed to then add all the references to the plugin automatically now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With