-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbuildGooglePlayAAB.sh
executable file
·60 lines (35 loc) · 1.78 KB
/
buildGooglePlayAAB.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/sh
set -e
function echoInfo() {
echo "[GP_AAB 打包验证]$1"
}
packageOutTempFile="$(pwd)/PackageOutTemp"
if [ ! -d "$packageOutTempFile" ]; then
echoInfo "PackageOutTemp 文件不存在,不需要删除"
else
echoInfo "PackageOutTemp 已存在,需要先删除"
rm -rf $packageOutTempFile
fi
echoInfo "$packageOutTempFile"
echoInfo "开始处理打包 aab 文件..."
#运行自定义的 gradle 任务,打包 aab 文件,并且拷贝到文件夹 GooglePlayTemp 中
./gradlew clean buildAabRelease
echoInfo "1. aab 包打包完成"
echoInfo "2. 获取 aab 包路径..."
allAabFiles="$(cd "$(pwd)/PackageOutTemp" && ls | grep aab)"
echoInfo " 获取到 aab 包路径:$allAabFiles"
echoInfo "3. 获取设备的 spec.json 文件..."
# 获取连接设备的配置 json 文件,主要是为了避免生成比较全面的 apks 文件【时间会长很多】
device_spec_file="$(pwd)/PackageOutTemp"/device-spec.json
bundletool get-device-spec --output=$device_spec_file --overwrite
echoInfo " 设备的 spec.json 文件获取成功: $device_spec_file"
echoInfo "4. 正在生成 apks 包..."
apks_file="$(pwd)/PackageOutTemp"/app_bundle.apks
bundletool build-apks --bundle="$(pwd)/PackageOutTemp"/$allAabFiles --device-spec=$device_spec_file --output=$apks_file --ks=./app/release.jks --ks-pass=pass:fireantzhang --ks-key-alias=fireantzhang --key-pass=pass:fireantzhang --overwrite
echoInfo " 已经生成 apks 包:$apks_file"
echoInfo "5. 正在安装 apks 包..."
bundletool install-apks --apks=$apks_file
echoInfo " 已经安装到手机"
echoInfo "6. 正在启动应用..."
adb shell am start -n "com.fireantzhang.aabdemo/com.fireantzhang.aabdemo.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
echoInfo " 应用已经启动..."