Install Cordova
sudo npm install -g cordova
Create Cordova Project
cordova create android-app com.dls [project-name]
Move dist
(npm run build) directory to Cordova Project www
directory
Add andriod platfom
android-app project root run command
cordova platforms add android --save
Check environment
android-app project root run command
cordova requirements
Install Android Studio
- Extract to
/usr/local/
- Execute
./studio.sh
inandroid-studio/bin/
- create android project and set Android target (sdk)
Configure Android SDK environment
vim ~/.profile
add code
export ANDROID_HOME=$HOME/Android/Sdk export PATH=${PATH}:${ANDROID_HOME}/tools export PATH=${PATH}:${ANDROID_HOME}/platform-tools
Install Java jdk
url: www.oracle.com/technetwork…
Extract to /usr/local/
Configure Java jdk
vim /etc/profile
add code
export JAVA_HOME=/usr/local/jdk1.8.0_231 export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export PATH=$JAVA_HOME/bin:$PATH
source /etc/profile
e.g
$ java -version java version "1.8.0_231" Java(TM) SE Runtime Environment (build 1.8.0_231-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)
Install Gradle
mkdir /opt/gradle
Extract to /opt/gradle
vim /etc/profile
add code
export PATH=$PATH:/opt/gradle/gradle-6.0.1/bin
source /etc/profile
Check the environment again
android-app project root run command
cordova requirements
Generate apk
Generage key
keytool -genkey -v -keystore ./w.keystore -alias w.keystore -keyalg RSA -validity 2000
w@w:~/my/app/android-app$ keytool -genkey -v -keystore ./w.keystore -alias w.keystore -keyalg RSA -validity 2000 Enter keystore password: Re-enter new password: What is your first and last name? [Unknown]: What is the name of your organizational unit? [Unknown]:
create build.json
w@w:~/my/app/android-app$ vim build.json e.g { "android": { "release": { "keystore": "w.keystore", "alias": "w.keystore", "storePassword": "xxx", "password": "xxx" } } }
Generate apk
cordova build --release
w@w:~/my/app/android-app/platforms/android/app/build/outputs/apk/release$ ls app-release.apk output.json
Chrome Debug Andriod App
cordova run android
chrome://inspect/#devices
打包ios
cordova platforms add ios --save
cordova 项目根目录 build.json 中添加 ios