首页 > 代码库 > Cordova 学习步骤

Cordova 学习步骤

 

 

安装环境

Peng@PENG-PC ~
$ npm install -g cordova
npm WARN deprecated node-uuid@1.4.7: use uuid module instead
C:\Users\Peng\AppData\Roaming\npm\cordova -> C:\Users\Peng\AppData\Roaming\npm\n
ode_modules\cordova\bin\cordova
cordova@6.5.0 C:\Users\Peng\AppData\Roaming\npm\node_modules\cordova
├── underscore@1.7.0
├── q@1.0.1
├── nopt@3.0.1 (abbrev@1.0.9)
├── update-notifier@0.5.0 (is-npm@1.0.0, semver-diff@2.1.0, repeating@1.1.3,
chalk@1.1.3, string-length@1.0.1, configstore@1.4.0, latest-version@1.0.1)
├── insight@0.8.4 (object-assign@4.1.1, async@1.5.2, uuid@3.0.1, lodash.debou
nce@3.1.1, tough-cookie@2.3.2, chalk@1.1.3, configstore@1.4.0, os-name@1.0.3, re
quest@2.79.0, inquirer@0.10.1)
├── cordova-common@2.0.0 (q@1.4.1, cordova-registry-mapper@1.1.15, underscore
@1.8.3, unorm@1.4.1, semver@5.3.0, ansi@0.3.1, osenv@0.1.4, minimatch@3.0.3, she
lljs@0.5.3, glob@5.0.15, bplist-parser@0.1.1, elementtree@0.1.7, plist@1.2.0)
└── cordova-lib@6.5.0 (valid-identifier@0.0.1, cordova-registry-mapper@1.1.15
, opener@1.4.1, unorm@1.3.3, properties-parser@0.2.3, semver@4.3.6, nopt@3.0.6,
shelljs@0.3.0, dep-graph@1.1.0, glob@5.0.15, elementtree@0.1.6, aliasify@1.9.0,
tar@1.0.2, xcode@0.9.1, request@2.47.0, cordova-fetch@1.0.2, plist@1.2.0, init-p
ackage-json@1.9.4, cordova-serve@1.0.1, npm@2.15.11, cordova-js@4.2.1, cordova-c
reate@1.0.2)

Peng@PENG-PC ~
$ cordova -v
? May Cordova anonymously report usage statistics to improve the tool over time?
? May Cordova anonymously report usage statistics to improve the tool over time?
 No

You have been opted out of telemetry. To change this, run: cordova telemetry on.

6.5.0

Peng@PENG-PC ~
$ cordova -v
6.5.0

 

创建项目:

Peng@PENG-PC /D/home/cordova-workspace
$ cordova create mycordova com.example.hello helloWorld
Creating a new cordova project.

Peng@PENG-PC /D/home/cordova-workspace
$ cd mycordova/

Peng@PENG-PC /D/home/cordova-workspace/mycordova
$ cordova platforms ls
Installed platforms:

Available platforms:
  amazon-fireos ~3.6.3 (deprecated)
  android ~6.1.1
  blackberry10 ~3.8.0
  browser ~4.1.0
  firefoxos ~3.6.3
  webos ~3.7.0
  windows ~4.4.0
  wp8 ~3.8.2 (deprecated)

Peng@PENG-PC /D/home/cordova-workspace/mycordova
$ cordova platform add android
Adding android project...
Creating Cordova project for the Android platform:
        Path: platforms\android
        Package: com.example.hello
        Name: helloWorld
        Activity: MainActivity
        Android target: android-25
Subproject Path: CordovaLib
Android project created with cordova-android@6.1.2
Discovered plugin "cordova-plugin-whitelist" in config.xml. Adding it to the pro
ject
Fetching plugin "cordova-plugin-whitelist@1" via npm
Installing "cordova-plugin-whitelist" for android

               This plugin is only applicable for versions of cordova-android gr
eater than 4.0. If you have a previous platform version, you do *not* need this
plugin since the whitelist will be built in.


Peng@PENG-PC /D/home/cordova-workspace/mycordova
$ cordova build android
Error: Failed to find ANDROID_HOME environment variable. Try setting setting i
t manually.
Failed to find android command in your PATH. Try update your PATH to inclu
de path to valid SDK directory.

 

Cordova 学习步骤