Linux命令行打包Android应用 在Linux下通过命令行打包Android应用的方法
核子飞弹 人气:0本文介绍了在Linux下通过命令行打包Android应用的方法,分享给大家,具体如下:
Requirements
- Ubuntu 16.04
- sdk tools for linux
- Java 8
准备环境
安装Shell工具
sudo apt install -y wget unzip git
安装JDK
sudo apt install -y openjdk-8-jdk # 查看结果 java -version
初始化目录与环境变量
BUILD_BASE=`echo ~` export ANDROID_HOME=$BUILD_BASE/android_sdk mkdir -p $ANDROID_HOME export REPO_BASE=$BUILD_BASE/repo mkdir -p $REPO_BASE export REPO_USERNAME=xxx export REPO_PASSWORD=xxx export PROJECT_HOME=$REPO_BASE/android-preference export OUTPUT_RELEASE_DIR=$PROJECT_HOME/easy-preference/build/outputs/aar/release
安装SDK工具
cd $ANDROID_HOME # download wget https://dl.google.com/android/repository/sdk-tools-linux-4333796.zip # unzip unzip sdk-tools-linux-4333796.zip # export environment variables export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools
配置License
mkdir -p $ANDROID_HOME/licenses echo -e "\nd56f5187479451eabf01fb78af6dfcb131a6481e" > $ANDROID_HOME/licenses/android-sdk-license
下载源码
cd $REPO_BASE # clone git clone -b develop git clone https://$REPO_USERNAME:$REPO_PASSWORD@github.com/hziee514/android-preference.git # pull git pull origin develop:develop # branches git branch git checkout -b develop
构建
第一次运行时需要下载依赖项,可能要花很长时间
cd $PROJECT_HOME chmod +x gradlew ./gradlew :easy-preference:assembleRelease
输出
$OUTPUT_RELEASE_DIR/easy-preference-release.aar
加载全部内容