build(scripts): 各端 libbox 构建脚本修正 + 自动部署产物
排查 Android 打包"libbox.aar not found / Unresolved reference nekohasekai"踩坑:
- scripts/build-libbox.sh:
· 构建后自动部署产物到工程引用位置(android→app/kernel/dist/android/libbox.aar;
apple→client/{macos,ios}/Frameworks/Libbox.xcframework),不再留 /tmp 让人手动拷
· android 自动挑 NDK ≥28(未设 ANDROID_NDK_HOME 时):官方 build_libbox 拉 cronet-go,
其 libcronet.a 在 NDK 27 lld 链接报 unknown relocation(315)失败
· 头注释补全前置(NDK≥28 / JDK17 / gomobile 入 PATH)与产物路径
- app/kernel/build-android.sh:补 -javapkg io.nekohasekai —— 缺它产出默认包名 `libbox`,
与 Kotlin 的 io.nekohasekai.libbox 对不上、APK Kotlin 编译失败
- build.gradle:注释指明两条构建途径 + 包名必须 io.nekohasekai.libbox
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
# build-android.sh — gomobile bind sing-box libbox → dist/android/libbox.aar
|
||||
#
|
||||
# 与 scripts/build-libbox.sh android 的关系(两条都能产 app/kernel/dist/android/libbox.aar):
|
||||
# - 本脚本:裸 gomobile bind 本地 .build/singbox 源,tag 精简(无 tailscale/cronet)→
|
||||
# 体积小、NDK 27 也能链接。**必须带 -javapkg io.nekohasekai**(见下方 bind),否则
|
||||
# 产出包名是默认 `libbox`,与 Kotlin 的 io.nekohasekai.libbox 对不上、APK 编不过。
|
||||
# - scripts/build-libbox.sh:走上游官方 build_libbox,带 tailscale/cronet → 体积大、需 NDK ≥ 28。
|
||||
# 两者产出包名一致(io.nekohasekai.libbox),择一即可;product 是 gitignore 的,清掉就得重建。
|
||||
#
|
||||
# 用法: ./build-android.sh [--force]
|
||||
# --force 忽略已有产物,强制重新构建
|
||||
#
|
||||
@@ -155,6 +162,7 @@ LDFLAGS="-X github.com/sagernet/sing-box/constant.Version=${SINGBOX_VERSION} -X
|
||||
-target android/arm64,android/arm,android/amd64 \
|
||||
-androidapi 21 \
|
||||
-tags "${BUILD_TAGS}" \
|
||||
-javapkg io.nekohasekai \
|
||||
-o "${OUT_AAR}" \
|
||||
./experimental/libbox
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user