Package the Android build as an installable APK
The arm64 job stopped at the three shared libraries, so the only way to use them was to build a player around them. Let the libraries go into mpv-android's jniLibs and let Gradle assemble and sign the app instead. - copy libmpv.so, libjoc_core.so and libc++_shared.so into app/src/main/jniLibs/arm64-v8a - locate the SDK under buildscripts/sdk, accept its licences, and link the unpacked NDK where AGP looks for it - run assembleRelease with a throwaway injected signing key, so the APK installs without repository secrets - verify the signature when apksigner is available and upload the APK as mpv-joc-android-arm64-v8a-apk, keeping the bare libraries as before - cache the Gradle home between runs - document the artifact and how to pass the ad_joc options Checked locally: the workflow parses and every shell block passes bash -n; the Gradle build itself needs a CI run.
This commit is contained in:
1 parent
ecf14d8c32
commit
c45808135d
3 files changed
+118
-3
No files matched your search
@@ -161,6 +161,106 @@ jobs:
|
|||||||
path: dist/arm64-v8a/
|
path: dist/arm64-v8a/
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
|
|
||||||
|
- name: Install the native libraries into the app
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
abi=arm64-v8a
|
||||||
|
libs="$GITHUB_WORKSPACE/android/app/src/main/jniLibs/$abi"
|
||||||
|
mkdir -p "$libs"
|
||||||
|
cp "$GITHUB_WORKSPACE/android/buildscripts/prefix/arm64/lib/libmpv.so" "$libs/"
|
||||||
|
cp "$GITHUB_WORKSPACE/joc/build-android/libjoc_core.so" "$libs/"
|
||||||
|
source "$GITHUB_WORKSPACE/android/buildscripts/include/depinfo.sh"
|
||||||
|
libcxx=$(find "$GITHUB_WORKSPACE/android/buildscripts/sdk/android-ndk-${v_ndk}/toolchains/llvm/prebuilt" \
|
||||||
|
-path '*/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so' -print -quit)
|
||||||
|
test -n "$libcxx"
|
||||||
|
cp "$libcxx" "$libs/"
|
||||||
|
ls -lh "$libs"
|
||||||
|
|
||||||
|
- name: Cache the Gradle home
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.gradle/caches
|
||||||
|
~/.gradle/wrapper
|
||||||
|
key: gradle-${{ runner.os }}-${{ hashFiles('android/**/*.gradle', 'android/**/*.gradle.kts', 'android/gradle/wrapper/gradle-wrapper.properties') }}
|
||||||
|
|
||||||
|
- name: Build the Android APK
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
# download-sdk.sh unpacks the SDK under android/buildscripts/sdk; find
|
||||||
|
# the root by its platforms/ directory instead of hard-coding the name.
|
||||||
|
sdk_dir=""
|
||||||
|
for candidate in \
|
||||||
|
"$GITHUB_WORKSPACE/android/buildscripts/sdk/android-sdk" \
|
||||||
|
"$GITHUB_WORKSPACE/android/buildscripts/sdk"; do
|
||||||
|
if [ -d "$candidate/platforms" ]; then sdk_dir="$candidate"; break; fi
|
||||||
|
done
|
||||||
|
if [ -z "$sdk_dir" ]; then
|
||||||
|
echo "::error::no Android SDK (no platforms/ directory) under android/buildscripts/sdk"
|
||||||
|
find "$GITHUB_WORKSPACE/android/buildscripts/sdk" -maxdepth 2 -type d | head -40
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "ANDROID_SDK_ROOT=$sdk_dir" >> "$GITHUB_ENV"
|
||||||
|
echo "ANDROID_HOME=$sdk_dir" >> "$GITHUB_ENV"
|
||||||
|
echo "sdk.dir=$sdk_dir" > "$GITHUB_WORKSPACE/android/local.properties"
|
||||||
|
# Accept the SDK licences, so AGP may install whatever compileSdk or
|
||||||
|
# build-tools the app asks for instead of failing on an unaccepted hash.
|
||||||
|
if [ -x "$sdk_dir/cmdline-tools/latest/bin/sdkmanager" ]; then
|
||||||
|
yes | "$sdk_dir/cmdline-tools/latest/bin/sdkmanager" \
|
||||||
|
--sdk_root="$sdk_dir" --licenses >/dev/null 2>&1 || true
|
||||||
|
fi
|
||||||
|
# The NDK is unpacked as android-ndk-<release>; AGP looks it up by the
|
||||||
|
# source.properties revision under ndk/, so link it there too.
|
||||||
|
source "$GITHUB_WORKSPACE/android/buildscripts/include/depinfo.sh"
|
||||||
|
ndk="$GITHUB_WORKSPACE/android/buildscripts/sdk/android-ndk-${v_ndk}"
|
||||||
|
if [ -d "$ndk" ]; then
|
||||||
|
ndk_revision=$(sed -n 's/^Pkg\.Revision *= *//p' "$ndk/source.properties" 2>/dev/null | head -1)
|
||||||
|
mkdir -p "$sdk_dir/ndk"
|
||||||
|
ln -sfn "$ndk" "$sdk_dir/ndk/${ndk_revision:-$v_ndk}"
|
||||||
|
fi
|
||||||
|
# A throwaway key keeps the artifact installable; replace it with a
|
||||||
|
# repository secret when the build should be signed for distribution.
|
||||||
|
keytool -genkeypair -noprompt -keystore "$GITHUB_WORKSPACE/ci-signing.jks" \
|
||||||
|
-storepass android -keypass android -alias androiddebugkey \
|
||||||
|
-keyalg RSA -keysize 2048 -validity 10000 \
|
||||||
|
-dname "CN=mpv-joc CI, O=mpv-joc, C=CN"
|
||||||
|
cd "$GITHUB_WORKSPACE/android"
|
||||||
|
./gradlew --no-daemon --stacktrace assembleRelease \
|
||||||
|
-Pandroid.injected.signing.store.file="$GITHUB_WORKSPACE/ci-signing.jks" \
|
||||||
|
-Pandroid.injected.signing.store.password=android \
|
||||||
|
-Pandroid.injected.signing.key.alias=androiddebugkey \
|
||||||
|
-Pandroid.injected.signing.key.password=android
|
||||||
|
|
||||||
|
- name: Collect the APK
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
mkdir -p dist/apk
|
||||||
|
mapfile -t apks < <(find "$GITHUB_WORKSPACE/android/app/build/outputs/apk" -name '*.apk' -print)
|
||||||
|
if [ ${#apks[@]} -eq 0 ]; then
|
||||||
|
echo "::error::the Gradle build finished without an APK"
|
||||||
|
find "$GITHUB_WORKSPACE/android/app/build/outputs" -maxdepth 4 -type f | head -40
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
apksigner=$(find "$GITHUB_WORKSPACE/android/buildscripts/sdk" -path '*/build-tools/*/apksigner' -type f -print -quit 2>/dev/null || true)
|
||||||
|
for apk in "${apks[@]}"; do
|
||||||
|
if [ -n "$apksigner" ]; then
|
||||||
|
"$apksigner" verify --print-certs "$apk" | head -2
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
cp "${apks[@]}" dist/apk/
|
||||||
|
ls -lh dist/apk
|
||||||
|
|
||||||
|
- name: Upload the Android APK
|
||||||
|
if: success()
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: mpv-joc-android-arm64-v8a-apk
|
||||||
|
path: dist/apk/
|
||||||
|
if-no-files-found: error
|
||||||
|
|
||||||
- name: Upload JOC core even if mpv fails
|
- name: Upload JOC core even if mpv fails
|
||||||
if: failure()
|
if: failure()
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ mpv-joc/
|
|||||||
patches/ 同一改动的 diff(精确复现用)
|
patches/ 同一改动的 diff(精确复现用)
|
||||||
tools/ 锚点应用、构建、DLL 收集脚本
|
tools/ 锚点应用、构建、DLL 收集脚本
|
||||||
docs/ Android(libmpv.so)可行性调研
|
docs/ Android(libmpv.so)可行性调研
|
||||||
.github/workflows/ 补丁的 CI:构建产物 + 每日跟最新 mpv 检查
|
.github/workflows/ 补丁的 CI:构建产物(Windows / Android APK)+ 每日跟最新 mpv 检查
|
||||||
```
|
```
|
||||||
|
|
||||||
## 环境要求
|
## 环境要求
|
||||||
|
|||||||
+17
-2
@@ -53,10 +53,25 @@
|
|||||||
|
|
||||||
1. CI 先只做 **arm64 的 joc_core 交叉编译**,产出 `libjoc_core.so`。这一步最快暴露平台问题。
|
1. CI 先只做 **arm64 的 joc_core 交叉编译**,产出 `libjoc_core.so`。这一步最快暴露平台问题。
|
||||||
2. 再跑 mpv-android 的 buildscripts + 我们的 patch,产出 arm64 的 `libmpv.so`。
|
2. 再跑 mpv-android 的 buildscripts + 我们的 patch,产出 arm64 的 `libmpv.so`。
|
||||||
3. 在 mpv-android 里加一个最小 demo:`jniLibs/arm64-v8a/libjoc_core.so`,启动参数加
|
3. CI 把 `libmpv.so`、`libjoc_core.so`、`libc++_shared.so` 放进 app 的
|
||||||
`--ad=joc --ad-joc-hrtf=...`,用 `adb logcat -s mpv` 验证开始渲染。
|
`jniLibs/arm64-v8a/`,再 `./gradlew assembleRelease` 打出可安装的 APK;在 mpv 的
|
||||||
|
配置文件里加 `--ad=joc --ad-joc-hrtf=...`,用 `adb logcat -s mpv` 验证开始渲染。
|
||||||
4. 对拍:手机上把输出写成 WAV(`--ao=pcm`),拉回 PC 与 `joc_cli` 比较,确认 NEON 路径正确。
|
4. 对拍:手机上把输出写成 WAV(`--ao=pcm`),拉回 PC 与 `joc_cli` 比较,确认 NEON 路径正确。
|
||||||
|
|
||||||
|
## CI 产物
|
||||||
|
|
||||||
|
`build-android.yml` 的 arm64 任务现在产出两类工件:
|
||||||
|
|
||||||
|
- `mpv-ad-joc-android-arm64-v8a`:`libmpv.so`、`libjoc_core.so`、`libc++_shared.so`,
|
||||||
|
给已经自己编好的 mpv 用;
|
||||||
|
- `mpv-joc-android-arm64-v8a-apk`:上面这三个库已经打进 mpv-android 的
|
||||||
|
`jniLibs/arm64-v8a/`,由 `assembleRelease` 打包并签名,安装包直接可装。
|
||||||
|
|
||||||
|
签名用的是 CI 现场生成的临时 keystore(`-Pandroid.injected.signing.*`),只保证可安装,
|
||||||
|
不代表发布身份;要正式分发就把这段换成仓库 secret 里的 keystore。APK 里仍是原版
|
||||||
|
mpv-android 界面,`--ad=joc`、`--ad-joc-hrtf=` 等参数要在应用能读到的 `mpv.conf`
|
||||||
|
里给出,HRTF 文件也要放在应用可访问的目录。
|
||||||
|
|
||||||
## 参考
|
## 参考
|
||||||
|
|
||||||
- mpv-android 构建脚本:https://github.com/mpv-android/mpv-android/tree/master/buildscripts
|
- mpv-android 构建脚本:https://github.com/mpv-android/mpv-android/tree/master/buildscripts
|
||||||
|
|||||||
Reference in new issue
Block a user