CentOS7下安装安装android sdk & gradle
参考:
谢谢大佬!
https://blog.csdn.net/jiangxuexuanshuang/article/details/88600574
主要就是安装sdk 与 gradle
sdk下载地址:
https://developer.android.google.cn/studio
gradle下载地址:
https://services.gradle.org/distributions/
接下来是具体的配置:
step1:
首先在centOS环境通常我们将文件安装在/usr/local目录下
新建android-home文件夹,用来存放安装文件
mkdir android-home
切换到该目录下
cd android-home/
下载android sdk
wget https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip
解压:
unzip sdk-tools-linux-4333796.zip
在当前目录下新建文件夹 android-tools,并将解压得到的tools文件夹放到android-tools
mv tools/ android-tools
step2:
将android-home添加到环境变量
这里platform-tools这个文件夹还没有生成,别担心,后面执行了sdkmanager 的命令后,就会在android-home目录下生成了
echo "export ANDROID_HOME=/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
step3:
在android-home目录下新建android-sdk文件夹
[root@67 android-home]# mkdir android-sdk
切换到该目录下
cd android-sdk
安装这些命令:
sdkmanager "build-tools;19.1.0"
sdkmanager "build-tools;20.0.0"
sdkmanager "build-tools;21.1.2"
sdkmanager "build-tools;22.0.1"
sdkmanager "build-tools;23.0.1"
sdkmanager "build-tools;23.0.3"
sdkmanager "build-tools;24.0.0"
sdkmanager "build-tools;24.0.1"
sdkmanager "build-tools;24.0.2"
sdkmanager "build-tools;24.0.3"
sdkmanager "build-tools;25.0.0"
sdkmanager "build-tools;25.0.1"
sdkmanager "build-tools;25.0.2"
sdkmanager "build-tools;25.0.3"
sdkmanager "build-tools;26.0.0"
sdkmanager "build-tools;26.0.1"
sdkmanager "build-tools;26.0.2"
sdkmanager "build-tools;26.0.3"
sdkmanager "build-tools;27.0.0"
sdkmanager "build-tools;27.0.1"
sdkmanager "build-tools;27.0.2"
sdkmanager "build-tools;27.0.3"
sdkmanager "build-tools;28.0.0"
sdkmanager "build-tools;28.0.1"
sdkmanager "build-tools;28.0.2"
sdkmanager "build-tools;28.0.3"
sdkmanager "platform-tools"
sdkmanager "platforms;android-10"
sdkmanager "platforms;android-11"
sdkmanager "platforms;android-12"
sdkmanager "platforms;android-13"
sdkmanager "platforms;android-14"
sdkmanager "platforms;android-15"
sdkmanager "platforms;android-16"
sdkmanager "platforms;android-17"
sdkmanager "platforms;android-18"
sdkmanager "platforms;android-19"
sdkmanager "platforms;android-20"
sdkmanager "platforms;android-21"
sdkmanager "platforms;android-22"
sdkmanager "platforms;android-23"
sdkmanager "platforms;android-24"
sdkmanager "platforms;android-25"
sdkmanager "platforms;android-26"
sdkmanager "platforms;android-27"
sdkmanager "platforms;android-28"
可以先执行1行命令看一下是不是能正常运行
我执行了1个命令,出现了一个警告:Warning: File /root/.android/repositories.cfg could not be loaded.
说是是在目录 /root/.android/ 下没有找到文件repositories.cfg
解决办法:
使用touch命令在根目录下新建1一个repositories.cfg文件就可以了
touch ~/.android/repositories.cfg
然后执行sdkmanager xxxx就没问题了。
执行完的效果:
在android-home目录下多了4个文件夹
step4:
输入命令adb,出现如下信息,表示android sdk环境安装好了
接下来安装gradle环境
step1:
首先cd到android-home的同级目录
cd /usr/local
下载gradle,这里要注意下载与你项目编译使用的gradle版本保持一致,否则不能正常编译
wget https://services.gradle.org/distributions/gradle-4.6-bin.zip
解压到当前目录
unzip gradle-4.4-bin.zip
解压完的效果:
step2:
将gradle添加到环境变量:
echo "export GRADLE_HOME=/usr/local/gradle-4.6" >> /etc/profile
echo "export PATH=\$PATH:\$GRADLE_HOME/bin" >> /etc/profile
使配置生效
source /etc/profile
step3:
使用gradle -version命令查看gradle版本 验证gradle安装成功,
看到如下信息,就说明gradle环境搭建完毕了
[root@67 local]# gradle -version
------------------------------------------------------------
Gradle 4.6
------------------------------------------------------------
Build time: 2018-02-28 13:36:36 UTC
Revision: 8fa6ce7945b640e6168488e4417f9bb96e4ab46c
Groovy: 2.4.12
Ant: Apache Ant(TM) version 1.9.9 compiled on February 2 2017
JVM: 1.8.0_212 (Oracle Corporation 25.212-b04)
OS: Linux 3.10.0-957.21.2.el7.x86_64 amd64
解决警告问题参考了:
https://www.jianshu.com/p/d63353793b6f