创建清单文件的仓库,编写manifests

安装repo

由于网络原因使用镜像:

script
mkdir ~/bin
PATH=~/bin:$PATH
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo > ~/bin/repo
chmod a+x ~/bin/repo
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'

单独安装python3

script
mkdir install
cd install
#下载Python-3.7.9.tgz到此
tar -xzf Python-3.7.9.tgz
cd Python-3.7.9
./configure --prefix="/home/xxx/.python3.7.9" #必须要全路径
make
make install
export PATH=/home/xxx/.python3.7.9/bin:$PATH

安装pip和需要的库

script
cd ~
wget https://bootstrap.pypa.io/get-pip.py
.python3.7.9/bin/python3 get-pip.py
pip install --upgrade pip
pip install requests
pip install pymysql
pip install flask
解决wsl2 python3不能安装pip
script
#重装openssl
wget https://www.openssl.org/source/openssl-1.0.2q.tar.gz
tar -xvf openssl-1.0.2q.tar.gz openssl-1.0.2q
cd openssl-1.0.2q
./config --prefix=/usr/local/openssl
./config -t
make
sudo make install
cd ..
mkdir ~/.python3.7.9
vim Python-3.7.9/Modules/Setup.dist
#搜索 SSL 解开
#SSL=/usr/local/ssl
#_ssl _ssl.c \
# -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
# -L$(SSL)/lib -lssl -lcrypto

然后再编译和安装

准备.gitconfig和.ssh

这里是复制之前生成好的,注意是复制要修改权限

script
cp /mnt/e/Desktop/.gitconfig .gitconfig
cp /mnt/e/Desktop/.ssh .ssh -r
cd .ssh/
chmod 600 *
cd ..

开始同步

init时 -u 后是manifests的仓库路径,-m 后是指定manifests文件,未指定时默认为default.xml

script
mkdir AppCompile
cd AppCompile
repo init -u url/manifests.git -m xxx.xml
repo sync -j12

linux下gradle编译android app

  1. 安装openjdk
    sudo apt-get install openjdk-8-jdk
    export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

  2. 安装android sdk

    script
    cd install
    wget https://dl.google.com/android/repository/commandlinetools-linux-6858069_latest.zip
    unzip commandlinetools-linux-6858069_latest.zip
    mv cmdline-tools ../android_sdk

    export ANDROID_HOME=~/android_sdk/
    export PATH=$PATH:$ANDROID_HOME/tools/bin
    export PATH=$PATH:$ANDROID_HOME/platform-tools

    cd ..
    cd android_sdk/bin
    ./sdkmanager --licenses --sdk_root=${ANDROID_HOME}
  3. 进入project目录,若gradlew无运行权限添加运行权限
    gradlew:assembleRelease
    等待下载gradle和库 以及android sdk,android sdk下载可能失败,失败之后有些会重复下载,要到android_sdk目录下删除
    第一次下载完毕后也一定会报找不到android-x一次,重新运行即可正常编译