Install cordova on Mac, maccordova
First of all, this is my first blog. If anything is wrong, we will point out that we should actively modify it.
Cordova is the most frequently used HTML, CSS & JS for mobile App development multi-platform sharing a set of code, Chinese official website (http://cordova.axuer.com /), A lot of foreign websites have recently been too badly walled. Back to the question, we will introduce the installation of cordova and the "pitfall ".
1. installation environment
The Cordova command line runs on Node. js and can be installed through NPM. Open a command prompt or terminal, and then typenpm install -g cordova
2. Create an App
Cordova create hello com. example. hello HelloWorld
(This will create a required directory for your cordova application. By default,cordova create
Command to generate the skeleton of a web-based application. The project's home page iswww/index.html
File .)
3. Add a platform
All subsequent commands must be run in the project directory or any subdirectory of the project directory:
cd hello
Add a target platform to your App. We will add the 'ios 'and 'android' platforms and make sure they are saved inconfig.xml
Medium:
cordova platform add ios --save cordova platform add android --save
Check your current platform settings:
Cordova platform ls
Note: When you use CLI to create an application,NoModify/platforms/
Directory. This directory is usually overwritten when you are preparing to build an application or reinstall the plug-in.
4. Build an App
Run the following command:AllAdded platform construction:
cordova build
You can select to limit the platform range in each build-in this example, It is 'ios ':
cordova build ios
Let's talk about the pitfalls I met !!!
This is the table corresponding to the installation SDK on the official website and the Android API level. An error will be reported if you select the corresponding installation responsibilities according to this table.
The next step is to set the environment variables in Mac. Generally, Java systems come with their own environment variables. You do not need to install them (but you need to configure JAVA_HOME ),
Then install the SDK and install the Android Stand-alone SDK or Android Studio. If you plan to develop a new Cordova Android plug-in or use a native tool on the Android platform to run and debug it, use Android Studio. Otherwise, Android Stand-alone SDK Tools is enough to build and deploy Android applications. After installing the Android SDK, you need to install any SDK package at the target API level you want. We recommend that you install the highest level of SDK packages supported by cordova-android (see the above.
To enable the function to use Cordova's CLI tool properly, you need to set some environment variables. CLI will try to set these variables for you, but in some cases you need to manually set them. The following variables need to be updated:
On Mac or Linux, you can use a text editor to create or modify files.~/.bash_profile
. To set an environment variable, add a row and useexport
(Replace the path with your local installation path) as follows ):
export ANDROID_HOME=/Development/android-sdk/
To updatePATH
, Add a line similar to the following (the path is replaced with your local Android SDK installation path ):
export PATH=${PATH}:/Development/android-sdk/platform-tools:/Development/
android-sdk/tools
Restart the terminal or run the following command to view the changes:
source ~/.bash_profil
Then you need to install Gradle (android studio can be installed)
Basically, the test is complete. You can use a simulator (genymotion, etc.) or a real machine, hoping to help you.