Cordova环境安装与配置

Node不建议使用太高的版本,18.19.0就足够了

nvm list available
nvm install 18.19.0
nvm use 18.19.0
nvm ls


npm config get registry
https://registry.npmmirror.com/

 

npm config set registry https://registry.npm.taobao.org

npm config get registry

 

npm install -g cordova

 

1. 创建项目:cordova create 目录名称 id 应用名
cordova create abc org.penguin.cordova.abc Abc

2. 切换到项目目录
cd abc

3. 添加android平台(android,browser,electron,ios),配置文件config.xml(name, id)
cordova platform add android
Using cordova-fetch for cordova-android
Adding android project...
Creating Cordova project for the Android platform:
Path: platforms\android
Package: org.penguin.cordova.abc
Name: CordovaAbc
Activity: MainActivity
Android Target SDK: android-33
Android Compile SDK: 33
Subproject Path: CordovaLib
Subproject Path: app
Android project created with cordova-android@12.0.1

4. 修改repositories.gradle,配置国内镜像站点
ext.repos = {
maven { url 'https://maven.aliyun.com/repository/public/' }
maven { url 'https://maven.aliyun.com/repository/gradle-plugin/' }
maven { url 'https://maven.aliyun.com/repository/google/' }
google()
mavenCentral()
}

4. 装插件

cordova plugin add cordova-plugin-customurlscheme --variable URL_SCHEME=CordovaAbc
cordova plugin add cordova-plugin-file-opener2
cordova plugin add cordova-plugin-inappbrowser


cordova plugin add cordova-plugin-splashscreen

Unmet project requirements for latest version of cordova-plugin-splashscreen:
cordova-android (12.0.1 in project, >=3.6.0 <11.0.0 required)
Fetching highest version of cordova-plugin-splashscreen that this project supports: 6.0.1 (latest is 6.0.2)

 

cordova plugin add cordova-plugin-x-socialsharing
Installing "cordova-plugin-x-socialsharing" for android
Installing "es6-promise-plugin" for android
Subproject Path: CordovaLib
Subproject Path: app


Adding cordova-plugin-x-socialsharing to package.json

cordova plugin add cordova-plugin-x-toast
cordova plugin add cordova-support-android-plugincordova requirements

sdkmanager --licenses

cordova prepare

cordova requirements android
cordova build android --verbose
cordova run android

资源

下载Gradle各个版本

下载Android Studio各个版本

Cordova下命令学习

Powershell设置(如果在Windows下开发才会用到)

Android环境配置

Vue3的环境安装

posted @ 2024-01-21 21:54  心若向阳,次第花开  阅读(215)  评论(0编辑  收藏  举报