After building the APK, android/build.sh now picks the attached device (ANDROID_SERIAL for several), installs the APK (reinstalling on a signature mismatch), syncs the zh client into files/Client and, with --launch, wakes the phone and starts the app. Without a device it only builds. push-client.sh is now incremental (android/sync_client.py): the device keeps files/Client/.mt_sync (size, mtime, path of what the last sync wrote), so later syncs send only new and changed files as one tar streamed through `adb shell -T run-as` (no copy in /data/local/tmp) and delete the ones gone locally. Only game resources are synced; settings and logs the app writes there are kept. --locale zh rebuilds build/zh-locale/Client first when its inputs changed. android/adb_env.sh picks adb and falls back to server port 5038 when :5037 cannot bind. Verified against a fake adb device: first sync (1.4 GB, byte-identical), no-op resync, changed files, deletions, locale switch, --full, the install/launch path and the no-device path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2.3 KiB
Android 原生客户端测试
当前 APK 由 android/build.sh 构建,使用 SDL3 + Vulkan;应用包名 org.metin2port.client,ABI 为 arm64-v8a,最低 API 24。
安装和资源
./android/build.sh [Debug|Release] [--launch]
构建完成后,如果有一台已授权的设备(多台时用 ANDROID_SERIAL 指定),脚本会:
adb install -r安装 APK;签名不一致(别的机器的 debug key)时卸载重装,应用数据随之清空。- 运行
android/push-client.sh --locale zh,把资源同步到应用私有目录files/Client。中文资源build/zh-locale/Client的输入(data/zh_40250、scripts/build_zh_locale.py、Client/pack/Index)有变化时先重新生成。 - 带
--launch时唤醒手机并启动应用;锁屏状态下只提示解锁(锁屏启动会因 Vulkan surface 错误退出)。
没有设备时只构建 APK。其他选项:--no-deploy 只构建,--no-push 只安装,--locale XX 用 Client/locale_XX.cfg,--full-push 删除设备上的资源后全量重传。
资源同步是增量的:设备上的 files/Client/.mt_sync 记录上次写入的文件(大小、修改时间),之后只传新增和改动的文件,并删除本地已不存在的文件;第一次同步传完整的约 1.4 GB。只同步游戏资源(pack/、sound/、BGM/、channel.inf、locale*.cfg),应用自己写的设置和性能日志不会被覆盖或删除。单独同步资源:./android/push-client.sh [--locale zh] [--full] [--dry-run] [CLIENT_DIR]。
APK 本身包含 libmain.so、libSDL3.so、着色器和 Python 2.7 标准库,不包含 40250 客户端资源。
连服务器
adb shell am start -n org.metin2port.client/.MainActivity \
--es args "--live-server HOST:AUTH_PORT:GAME_PORT --login-screen"
从桌面图标启动(不传参数)时连接 MainActivity.DEFAULT_ARGS 里的真服登录界面;显式传入不含 --live-server 的参数时运行进程内假服。测试真服前确认模拟器/设备能访问相应主机与端口。用 adb logcat 查看崩溃和启动错误。adb devices -l 没有设备时,先连接模拟器或开启真机 USB 调试。
更详细的构建依赖与命令见 src/host/README.md。