Getting started with Cordova
1. Install JDK 8 and configure Environment Variables
JAVA_HOME C:\Program Files\Java\jdk1.8.0_144 CLASSPATH .;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;Path %JAVA_HOME%\bin;
2. Install android sdk and configure environment variables using the adt-bundle-windows-x86_64-20140702 integration package
ANDROID_HOME D:\work\adt-bundle-windows-x86_64-20140702\sdkPath %ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools;
3. Install gradle-4.2
GRADLE_HOME D:\work\gradle-4.2Path %GRADLE_HOME%/bin;
4. Install node. js
Path D:\work\node-v6.11.3-win-x64\;
5. Install cordova
npm install -g cordova --registry=https://registry.npm.taobao.org
The cnpm method is found online, but an error is reported.
Terminal input confirmation: cordova-v
Create the first application
Create an application
cordova create first com.example.first firstApp
Add Platform
cd firstcordova platform add android --registry=https://registry.npm.taobao.org --nofetch
(This step is very slow)
Compile an app
cordova build android
(There will be many problems in this step. Solve the problem one by one based on the reported errors. In my first example, I encountered the following problems)
1. Downloading https://services.gradle.org/distributions/gradle-3.3-all.zip failed, manually download
2. If the jvm memory is insufficient, adjust the settings under firstApp \ platforms \ android \ cordova \ lib \ builders \ GradleBuilder. js.
Row 59 args. push ('-Dorg. gradle. jvmargs =-xmx2048m'); 2014 is 1024
3. Insufficient android support for the sdk, which can be installed through SDK Manager.exe
Run app
Run cordova emulate android on the simulator
Run the cordova serve android browser on the browser to access http: // localhost: 8000.
Run cordova run android on a real machine
Notes for importing firstApp using eclipse
1. Do not select Copy projects into workspace. Simply develop the firstApp.
2. The source code of www under firstApp must use cordova to build android before it can be packaged into firstApp \ platforms \ android \ assets \ www for release,
Therefore, before development, select which directory to use as the development site. Do not edit the two directories at the same time to prevent the www under firstApp from overwriting the edited www under assets, resulting in loss of development code.