I. Configuring the relevant environment
1, install JDK Jdk-7u79-windows-x64.exe (should be 64-bit Server VM version, if not need to swap otherwise eclipse does not start up)
Configuring Environment variables
2, install Node,node-v4.2.4-x64.msi
3, install Cordova. Command: NPM install-g [email protected] Version number (if the latest, you do not need to add the @ version number)
4. Install the SDK. Installer_r24.3.3-windows.exe
5, install apache-ant, copy apache-ant-1.9.6-bin folder to any location, and configure Ant_home
6, install ADT, can be downloaded from the Internet after installation, can also be installed online, but are very slow. You can copy all the contents of the Android-sdk folder to any location and can be placed in the same directory as the Apache-ant-1.9.6-bin
Configuring the environment variable Android_home refers to the ANDROID-SDK directory
7. Open the Eclipse.exe in eclipse-sdk-3.7.2-win32-x86_64 to start eclipse;
Modify: The SDK path makes it point to the ANDROID-SDK directory. preferences–>android
8, restart Eclipse
9,eclipse Connecting the phone:
A, connect the phone to the computer to install the mobile phone driver
b, turn on the USB interlock function by turning on the developer mode in the phone
Ii. Creating a project (using the command line)
1. Installing Phonegap,cordova
Command:
NPM install-g PhoneGap
NPM install-g [email protected] (with version number 4.2.0 as an example)
2. View the version number
Command:
Phonegap-version
Cordova-version
3. Create a PhoneGap project
Command:
1. Switch letter (need to create a project directory, example: D:CD demo)
2.cordova Create Hello Com.example.hello HelloWorld (creates a HelloWorld project under the Hello folder)
3.CD Hello
4.cordova Platform Add Android
5.cordova Build
(If there is no problem, the project is created at this point.) Android works in D:demo/hello/platforms/android)
Third, write plug-ins
1. Import the created project to eclipse (file–>import–>android–>existing Android Code into Workspace)
Note: After you import the project, you need to modify the WWW folder and the root directory of the. config file
(Right-click on the corresponding file, select the propreties option for path modification)
When you have finished editing, click Project–>clean
2. Writing plugins
<1> Configure Cordova _plugins.js file
Create the Cordova _plugins.js file under the WWW folder.
There are 2 places to configure:
(1) module.exports= [{}];
File represents the interface location written by JavaScript
ID stands for unique
Merges (Clobbers) represents the statement you call this interface in JavaScript (like Getapplication () in activity and so on; it's a call statement)
(2) Module.exports.metadata = {}
Configure ID label random (do not repeat with other labels)
<2> writing JavaScript interface files (bluetooth.js)
<3> configure the CONFIG. res/xml directory in the
The Name property of the feature is very important
Name must be the class name called in step <2> function
The Value property specifies the Java file (namespace) of the plug-in in the SRC directory
<4> calling plugins in JavaScript
Method:
Iv. compile the project, call the plugin
Custom plug-in class Myplugins inherits from Cordovaplugin Override Execute () method to implement interaction with JS
(If there is an error, please correct me!) )
PHONEGAP (Cordova) enables JavaScript to interact with Android with a custom plugin plugin