码迷,mamicode.com
首页 > 移动开发 > 详细

centos7.6 nodejs开发及打包android apk环境,涉及vscode、nodejs、cordova、pm2、jdk8、gradle、android sdk、

时间:2020-05-17 23:10:56      阅读:125      评论:0      收藏:0      [点我收藏+]

标签:yarn   oracle   zh-cn   tao   evel   java_home   有用   vscode   package   

安装vscode
下载vscode https://code.visualstudio.com/

安装vscode依赖
yum install libXScrnSaver -y

安装vscode
cd ~
wget https://vscode.cdn.azure.cn/stable/ff915844119ce9485abfe8aa9076ec76b5300ddd/code-1.44.2-1587059974.el7.x86_64.rpm
rpm -ivh code-1.44.2-1587059974.el7.x86_64.rpm
启动vscode
code --user-data-dir

======================================================================================================================

安装nodejs
下载地地址 https://nodejs.org/en/download/
cd ~
wget https://nodejs.org/dist/v12.16.2/node-v12.16.2-linux-x64.tar.xz
tar -xvf node-v12.16.2-linux-x64.tar.xz
ln -s ~/node-v12.16.2-linux-x64/bin/node /usr/bin/node
ln -s ~/node-v12.16.2-linux-x64/bin/npm /usr/bin/npm
node -v
npm --version

======================================================================================================================

安装 cordova
查看npm根目录 应该是 /usr/local/lib/node_modules
npm root –g
如果不是 执行
npm config set prefix /usr/local
npm install -g cordova --registry https://registry.npm.taobao.org
//npm install -g ionic --registry https://registry.npm.taobao.org 可以不要
cordova –v

#cordova requirements
#cordova platform add android
#cordova run android
#https://cordova.apache.org/#getstarted
#http://cordova.axuer.com/
#http://cordova.axuer.com/docs/zh-cn/latest/guide/cli/index.html

======================================================================================================================

安装 pm2
npm install -g pm2 --registry https://registry.npm.taobao.org
pm2 -v
安装yarn
curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo 这句是否有用存疑
npm install yarn –g
yarn -v

======================================================================================================================

安装jdk 8
查看并删除原jdk
yum list installed java-*

#已加载插件:fastestmirror, langpacks
#Loading mirror speeds from cached hostfile
# * base: mirrors.aliyun.com
# * extras: mirrors.aliyun.com
# * updates: mirrors.huaweicloud.com
#已安装的软件包
#javapackages-tools.noarch 3.4.1-11.el7
#java-1.7.0-openjdk.x86_64 1:1.7.0.251-2.6.21.0.el7_7 @updates
#java-1.7.0-openjdk-headless.x86_64 1:1.7.0.251-2.6.21.0.el7_7 @updates
#java-1.8.0-openjdk.x86_64 1:1.8.0.242.b08-0.el7_7 @updates
#java-1.8.0-openjdk-headless.x86_64 1:1.8.0.242.b08-0.el7_7 @updates
#javapackages-tools.noarch 3.4.1-11.el7 @base

yum remove java-*

下载 jdk-8u251-linux-x64.rpm
cd ~
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "https://download.oracle.com/otn/java/jdk/8u251-b08/3d5a2bb8f8d4428bbe94aed7ec7ae784/jdk-8u251-linux-x64.rpm?AuthParam=1587957985_9dcb462a62baff7ec526ba0e82c6e088"
rpm -ivh jdk-8u251-linux-x64.rpm
java -version

vi /etc/profile.d/java.sh
#添加以下内容
#!/bin/bash
JAVA_HOME=/usr/java/jdk1.8.0_251-amd64/
PATH=$JAVA_HOME/bin:$PATH
export PATH JAVA_HOME
export CLASSPATH=.
#添加以上内容

chmod +x /etc/profile.d/java.sh
source /etc/profile.d/java.sh

java -version
======================================================================================================================
安装 gradle https://gradle.org/releases
wget https://downloads.gradle.org/distributions/gradle-4.10.3-all.zip
unzip gradle-4.10.3-all.zip
mv gradle-4.10.3 /usr/local/gradle-4.10.3

vi /etc/profile
#添加以下内容
export GRADLE_HOME=/usr/local/gradle-4.10.3
export PATH=${GRADLE_HOME}/bin:${PATH}
export GRADLE_USER_HOME=/usr/local/gradle-4.10.3/.gradle
#添加以上内容

source /etc/profile

gradle -version
======================================================================================================================

安装 android sdk 下载页面 https://developer.android.com/studio?pkg=tools
mkdir /usr/local/android-home
cd /usr/local/android-home
wget https://dl.google.com/android/repository/commandlinetools-linux-6200805_latest.zip
unzip commandlinetools-linux-6200805_latest.zip
mv tools/ android-tools

执行以下内容 添加到环境变量

echo "export ANDROID_HOME=/usr/local/android-home" >> /etc/profile
echo "export ANDROID_SDK_ROOT=/usr/local/android-home" >> /etc/profile
echo "export PATH=\$PATH:\$ANDROID_HOME/android-tools:\$ANDROID_HOME/android-tools/bin:\$ANDROID_HOME/platform-tools" >> /etc/profile
source /etc/profile

echo "$PATH"

sdkmanager --version
报错
java.lang.IllegalArgumentException
at com.android.sdklib.tool.sdkmanager.SdkManagerCliSettings.<init>(SdkManagerCliSettings.java:428)
at com.android.sdklib.tool.sdkmanager.SdkManagerCliSettings.createSettings(SdkManagerCliSettings.java:152)
at com.android.sdklib.tool.sdkmanager.SdkManagerCliSettings.createSettings(SdkManagerCliSettings.java:134)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:57)
at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
加参数 --sdk_root=$ANDROID_HOME
sdkmanager --version --sdk_root=$ANDROID_HOME


以下sdk按需安装
sdkmanager "platform-tools" --sdk_root=$ANDROID_HOME

sdkmanager "build-tools;19.1.0" --sdk_root=$ANDROID_HOME
sdkmanager "build-tools;20.0.0" --sdk_root=$ANDROID_HOME
sdkmanager "build-tools;21.1.2" --sdk_root=$ANDROID_HOME
sdkmanager "build-tools;22.0.1" --sdk_root=$ANDROID_HOME
sdkmanager "build-tools;23.0.1" --sdk_root=$ANDROID_HOME
sdkmanager "build-tools;23.0.3" --sdk_root=$ANDROID_HOME
sdkmanager "build-tools;24.0.0" --sdk_root=$ANDROID_HOME
sdkmanager "build-tools;24.0.1" --sdk_root=$ANDROID_HOME
sdkmanager "build-tools;24.0.2" --sdk_root=$ANDROID_HOME
sdkmanager "build-tools;24.0.3" --sdk_root=$ANDROID_HOME
sdkmanager "build-tools;25.0.0" --sdk_root=$ANDROID_HOME
sdkmanager "build-tools;25.0.1" --sdk_root=$ANDROID_HOME
sdkmanager "build-tools;25.0.2" --sdk_root=$ANDROID_HOME
sdkmanager "build-tools;25.0.3" --sdk_root=$ANDROID_HOME
sdkmanager "build-tools;26.0.0" --sdk_root=$ANDROID_HOME
sdkmanager "build-tools;26.0.1" --sdk_root=$ANDROID_HOME
sdkmanager "build-tools;26.0.2" --sdk_root=$ANDROID_HOME
sdkmanager "build-tools;26.0.3" --sdk_root=$ANDROID_HOME

sdkmanager "build-tools;27.0.0" --sdk_root=$ANDROID_HOME
sdkmanager "build-tools;27.0.1" --sdk_root=$ANDROID_HOME
sdkmanager "build-tools;27.0.2" --sdk_root=$ANDROID_HOME
sdkmanager "build-tools;27.0.3" --sdk_root=$ANDROID_HOME

sdkmanager "build-tools;28.0.0" --sdk_root=$ANDROID_HOME
sdkmanager "build-tools;28.0.1" --sdk_root=$ANDROID_HOME
sdkmanager "build-tools;28.0.2" --sdk_root=$ANDROID_HOME
sdkmanager "build-tools;28.0.3" --sdk_root=$ANDROID_HOME

sdkmanager "platforms;android-10" --sdk_root=$ANDROID_HOME
sdkmanager "platforms;android-11" --sdk_root=$ANDROID_HOME
sdkmanager "platforms;android-12" --sdk_root=$ANDROID_HOME
sdkmanager "platforms;android-13" --sdk_root=$ANDROID_HOME
sdkmanager "platforms;android-14" --sdk_root=$ANDROID_HOME
sdkmanager "platforms;android-15" --sdk_root=$ANDROID_HOME
sdkmanager "platforms;android-16" --sdk_root=$ANDROID_HOME
sdkmanager "platforms;android-17" --sdk_root=$ANDROID_HOME
sdkmanager "platforms;android-18" --sdk_root=$ANDROID_HOME
sdkmanager "platforms;android-19" --sdk_root=$ANDROID_HOME
sdkmanager "platforms;android-20" --sdk_root=$ANDROID_HOME
sdkmanager "platforms;android-21" --sdk_root=$ANDROID_HOME
sdkmanager "platforms;android-22" --sdk_root=$ANDROID_HOME
sdkmanager "platforms;android-23" --sdk_root=$ANDROID_HOME
sdkmanager "platforms;android-24" --sdk_root=$ANDROID_HOME
sdkmanager "platforms;android-25" --sdk_root=$ANDROID_HOME
sdkmanager "platforms;android-26" --sdk_root=$ANDROID_HOME

sdkmanager "platforms;android-27" --sdk_root=$ANDROID_HOME
sdkmanager "platforms;android-28" --sdk_root=$ANDROID_HOME


======================================================================================================================
安装依赖(vscode 终端)
sudo npm install --registry https://registry.npm.taobao.org
需要配置android、ios环境,参考https://cordova.apache.org/#getstarted
http://cordova.axuer.com/
http://cordova.axuer.com/docs/zh-cn/latest/guide/cli/index.html

centos7.6 nodejs开发及打包android apk环境,涉及vscode、nodejs、cordova、pm2、jdk8、gradle、android sdk、

标签:yarn   oracle   zh-cn   tao   evel   java_home   有用   vscode   package   

原文地址:https://www.cnblogs.com/youjiao/p/12907594.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!