1. Pre-installation work
1), install Node.js
It has npm built in, which can be used to install Cordova, add the path to the environment variable, so that you can use npm commands anywhere in cmd
2), install the Android SDK
2. Install cordova and create an application
1), install cordova
Go to any path and execute the following commands. If npm does not find it, you need to add the Node.js installation path to the environment variable in the first step
- npm install -g cordova
Check
the cordova version, if the installation is successful, there will be the following signs
- cordova -v
2), create an application
- cordova create CordovaProject io.cordova.hellocordova
- CordovaProject is the name of the directory where the application was created.
- io.cordova.hellocordova is the default reverse domain value. If possible, you should use your own domain value.
- CordovaApp is the title of your app.
If the operation is successful, this folder will appear
3), add platform
Go to the CordovaProject folder and run the following command
- cordova platform add android
Then the android folder will appear under the \CordovaProject\platforms path
3. Import idea to run
1), import the project
2), just go to the next step
3), configure the operating environment
The left border is the Java package and the Android package, and the right side indicates the path of the SDK installation, the Android version and the Java version used.
Configure to run
Choose the Android operating environment
Select Project SDK for each Modules
Then open the emulator, run the project, and luck will succeed. But I had a situation where dx.jar could not be read before, and then I downloaded a dx.jar package on the Internet and replaced it. The guess is that the package was damaged when downloading.