Cordova + vue project package to build Android applications

Environment Preparation Windows

1. First install jdk,
https://www.oracle.com/java/technologies/javase-jdk8-downloads.html

PS: These remind students and jdk suggest to install the C drive by default, otherwise the
version detection is too frustrating :

java-version 

is currently required to log in when downloading java jdk lower than jdk1.8 on the official website, share an account here, easy to download  (PS: This is found online) Oracle account (reproduced)
[email protected]  
Password: Oracle123
Source address: https://blog.csdn.net/Stars_min/article/details/91659994

 

2. Android SDK download

https://www.androiddevtools.cn/

 

3. Install Gradle


https://services.gradle.org/distributions/

Version detection:

Gradle -v

 

 

The system variable configuration is newly added as follows: 
JAVA_HOME C: \ Program Files \ Java \ jdk1. 8. 0_251 
CLASSPATH.; % JAVA_HOME% \ lib \ dt.jar;% JAVA_HOME% \ lib \ tools.jar 

Path The following is added: 
Path
 % JAVA_HOME% \ jre \ bin
 % JAVA_HOME% \ bin 
E: \ Adnroid \ Tools \ android -sdk_r24. 4.1 -windows \ android-sdk- windows 
E: \ Adnroid \ Tools \ android -sdk_r24. 4.1 -windows \ android-sdk- windows \ platform- tools 
E: \ Adnroid \ Tools \ android -sdk_r24. 4.1 -windows \ android-sdk-windows \ build- tools 
E: \ Adnroid \ Tools \ android -sdk_r24. 4.1-windows\android-sdk-windows\tools
E:\Adnroid\Tools\android-sdk_r24.4.1-windows\android-sdk-windows\cmdline-tools\latest

 

Cordova configuration


Cordova Chinese Network: http://cordova.axuer.com/

1.
The prerequisite for installing cordova is that node has been installed.
Node installation: https://nodejs.org/zh-cn/

2. Global installation

npm install- g cordova 
version detection: cordova -v

 

3. New cordova project

cordova create Chy.Demo.Cordova org.apache.cordova.ChyApp Chy.Demo 

directory structure annotation: 
Chy.Demo.Cordova: cordova directory name 
org.apache.cordova.ChyApp: package name 
Chy.Demo project name

 

4. Generate cordova platform add android to create the cordova library required by the Android platform

cordova platform add android

 

PS: Most of the work has been completed here! ! !

Vue project construction


1. First install Vue-cli scaffolding globally

npm install -g vue
npm install -g vue-cli

 

2. Use the command line to create a Vue project

vue init webpack Chy.Demo

 

3.Modify the Vue project config / index.js file.

index: path.resolve(__dirname, '../www/index.html'),
assetsRoot: path.resolve(__dirname, '../www'),
assetsSubDirectory: '',
assetsPublicPath: '',

4. Use npm run build to compile and release the project

Android apk generation

1. Overwrite the files in the generated www folder directory to the www in the Cordova project

2. Execute command to compile and generate apk file,
cordova build android

3, Apk file
project under \ platforms \ android \ app \ build \ outputs \ apk \ debug folder

4. Before packaging and debugging, first check whether the AndroidSDK is correctly installed and execute the command to check
cordova requirements

5. Via command

cordova serve android

 

Then you can access the page in the browser through http: // localhost: 8000 / android / www / index.html # / (just like seeing the page in your phone)

 

PS: I can see this step and can basically play happily! ! !

 

Guess you like

Origin www.cnblogs.com/hanlongZ/p/12721441.html