Create a new cordova application

Using the command line (the command line in this example uses the as or webstrom command line), enter the following command in any directory to create a new cordova application

cordova create capp1 com.cesc.ewater.capp1

Where capp1 is the application name (project name), and com.cesc.ewater.capp1 is the package name

 

After creation, the following directory can be seen

 

Enter the directory of capp1 from the command line and execute the command to add the Android platform to capp1

PS: cordova supports mobile development platforms such as Android and ios

There will be more directories after completion

 

Then open Android Studio (hereinafter referred to as as), open the following directory

PS: This android directory was newly created when the Android platform was added. The android directory contains a set of native Android codes, so it can be opened with as

 

After as is turned on, due to the uncertainty of as, the uncertainty of configuration and development environment may cause many problems, and I cannot explain them one by one here. The following is only for the problems I encountered.

 

Open the following files

Add maven {url 'http://maven.aliyun.com/nexus/content/groups/public/'} in the following two places respectively

PS: The screenshot is the effect after adding

PS: The repositories node represents the remote library for loading dependencies. Since foreign libraries such as mavenCentral (maven central library) and jcenter are usually not connected, it is necessary to add the domestic Alibaba maven image, which is similar to the maven configuration of java

 

Open the following files

Modify it as follows: distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip

PS: This modification may only apply to my situation. In my case, the file path of gradle 4.x is given by default, but this code uses gradle version 2.2.1, so the address of the gradle file needs to be modified.

PS: Although it is theoretically possible to use a higher version of gradle, it is not recommended to use it. The syntax of different versions of gradle configuration files is different, not just simply changing the version number

 

At this point, there should be this prompt on the as editor, click Try again

Then as will be processed according to the new gradle configuration just now, after waiting for a while, it should be able to compile successfully

Compile it, if no error is reported

 

Plug in the phone and start debugging

 

What your phone looks like when you're successful

 

At this point, the new cordova application is completed. Of course, it is meaningless to create a new application. Please read the next article.

Reprinted in: https://www.cnblogs.com/cannel/p/11074359.html

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=324121287&siteId=291194637