---- Updated at 2020/07/17
文章不全, 缺了cordova requirements如何解决的描述
正在尝试用mac重新搭建。。。
ubuntu18 配置cordova的Android编译环境,大致命令如下:
sudo apt update
sudo apt install -y nodejs
# ---- Install yarn
sudo su
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
apt update
apt install -y yarn
exit
# ----
yarn config set registry https://registry.npm.taobao.org --global
yarn config set disturl https://npm.taobao.org/dist --global
yarn global add cordova
sudo apt install openjdk-8-jdk
# ---- Update nodejs and npm
sudo apt install -y npm
npm config set registry https://registry.npm.taobao.org
npm config get registry
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
sudo npm i -g npm
# ----
# ---- Install zsh
mkdir ~/softwares
cd ~/softwares
wget https://www.shequyi.fun/media/install-oh-my-zsh.sh
chmod +x install-oh-my-zsh.sh
./install-oh-my-zsh.sh
echo "[ -s \$HOME/.bash_aliases ] && source \$HOME/.bash_aliases" >> $HOME/.zshrc
echo "[ -s \$HOME/.local/bin ] && export PATH=\$HOME/.local/bin:/usr/local/bin:\$PATH" >> $HOME/.zshrc
# ----
# ---- Install and upgrade gradle
sudo apt install -y gradle
sudo apt install -y zip
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk install gradle
sdk install groovy
# ----
# ---- Install android sdk
wget http://dl.google.com/android/android-sdk_r24.4.1-linux.tgz
tar -zxf android-sdk_r24.4.1-linux.tgz
sudo mv android-sdk-linux /usr/local
echo '# set PATH for android
export SDK_HOME=/usr/local/android-sdk-linux
if [ -d "$SDK_HOME/tools" ] ; then
PATH=$SDK_HOME/tools:$SDK_HOME/platform-tools:$PATH
fi
' >> ~/.zshrc
source ~/.zshrc
android update sdk --no-ui
# -----
# ----- Config gradle source mirror
echo 'allprojects {
repositories {
def ALIYUN_REPOSITORY_URL = "http://maven.aliyun.com/nexus/content/groups/public"
def ALIYUN_JCENTER_URL = "http://maven.aliyun.com/nexus/content/repositories/jcenter"
all {
ArtifactRepository repo ->
if (repo instanceof MavenArtifactRepository) {
def url = repo.url.toString()
if (url.startsWith("https://repo1.maven.org/maven2")) {
project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_REPOSITORY_URL."
remove repo
}
if (url.startsWith("https://jcenter.bintray.com/")) {
project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_JCENTER_URL."
remove repo
}
}
}
maven {
url ALIYUN_REPOSITORY_URL
url ALIYUN_JCENTER_URL
}
}
}
' > $HOME/.gradle/init.gradle
# ----
Usage
cordova create myapp
cd myapp
cordova platform add android
cordova build
Android WebViews https://cordova.apache.org/docs/en/9.x/guide/platforms/android/webview.html
find . -name 'framework'
# ./node_modules/cordova-android/framework
cd ./node_modules/cordova-android/framework
ant jar
ls
# cordova-8.0.0.jar ...
cd -
cp ./node_modules/cordova-android/framework/cordova-8.0.0.jar platforms/android/app/src/main/libs
网友评论