在 Apple Vision Pro 上运行 Android ARM64 VR APK
Run Android ARM64 VR APKs on Apple Vision Pro

原始链接: https://github.com/shinyquagsire23/Klepton

**Klepton** 使 Android ARM64 VR APK 能够在 Apple Vision Pro 和 macOS 上运行,且无需 JIT。它通过自定义链接器(`klepton-ld`)将 Android `.so` 库转换为 Apple 兼容格式(`.dylib` 和 `.framework`),随后将其链接至 Klepton 运行时。 该系统通过将 Bionic 和 NDK 函数(如 JNI、ALooper 和 ANativeWindow)映射到 Apple 的原生对应项,来处理 Android 的核心依赖。在图形处理方面,它将 GLES 3.2 转换为 ANGLE(Metal 后端),并将 Vulkan 转换为 MoltenVK。为确保兼容性,`klepton-ld` 会自动修补 x18 寄存器的使用(这是 Android 和 macOS 之间常见的冲突),将其重定向到线程本地存储槽位。 尽管目前该项目主要针对 Java 精简型应用(绕过了对 ART/JVM 的需求),但其功能已相当出色;《节奏光剑》(*Beat Saber*)已能在 visionOS 和 macOS 上运行。未来的开发重点在于提高通用性、优化构建工具,并扩展对 Steam VR Link 的支持。虽然一些依赖 JIT 的脚本运行时可能最终需要额外的实现,但 Klepton 为将基于 Android 的 VR 体验引入 Apple 生态系统提供了一个稳固的基础。

Hacker News 最新 | 过往 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 在 Apple Vision Pro 上运行 Android ARM64 VR APK (github.com/shinyquagsire23) 6 分,由 LorenDB 于 1 小时前提交 | 隐藏 | 过往 | 收藏 | 讨论 帮助 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 加入 YC | 联系 搜索:
相关文章

原文

Running Android ARM64 VR APKs on Apple Vision Pro, no JIT required!

klepton-ld translates Android .so libraries into loadable Apple .dylib and .framework libraries, which then link into the Klepton runtime. Klepton currently focuses on Java-thin applications only (no ART, no JVM).

For graphics, GLES 3.2 is translated to a vendored ANGLE GLES 3.0 (with its Metal backend), and Vulkan is translated to MoltenVK.

┌─────────────────────────────────────────────────────────────────┐
│  GUEST (translated Mach-O, instruction bytes mostly unmodified) │
│  libil2cpp · libunity · libunityopus · libmain · burst · ...    │
└─────────────────────────────────────────────────────────────────┘
    ↕ imports resolved to Klepton runtime in `klepton-ld`
┌─────────────────────────────────────────────────────────────────┐
│  libklepton_bionic   libc/libm/libdl/pthread/liblog → libSystem │
│  libklepton_ndk      ALooper · ANativeWindow · ASensor · AAsset │ 
│  libklepton_jni      synthetic JavaVM / JNIEnv                  │
│  libklepton_ovrp     ovrp_* reimplementation                    │
│  ...                                                            │
└─────────────────────────────────────────────────────────────────┘
    ↕ Frontend platform (`mains`) and OS-specifics
┌─────────────────────────────────────────────────────────────────┐
│  MoltenVK (Vulkan → Metal)     ANGLE (GLES 3.0)                 │
│  Compositor Services · ARKit · GameController · AVAudioEngine   │
└─────────────────────────────────────────────────────────────────┘

While both Android and macOS reserve x18, some (a lot of) older Android applications still use x18, and macOS zeros x18 on context switches. All usage of x18 is patched by klepton-ld so that per-library TLS slots are used instead.

Klepton also has the ability to load and patch .so files at runtime with mmap, but this is only really useful on macOS where JIT is actually allowed. It's likely that some applications will require JIT if they happen to utilize scripting runtimes that expect it (LuaJIT, V8, whatever else).

See BUILDING.md for the full guide. The short version:

brew install pkg-config sdl3 apktool          # host dependencies
apktool d -f -o beatsaber beatsaber.apk       # you supply the APK; see BUILDING.md
make check                                    # full regression sweep

Quick run scripts:

./build_run_viewer.sh # build and run macOS Beat Saber frontend
./build_run_vpro.sh   # build and run Vision Pro Beat Saber frontend
./build_run_slink.sh --shell --view  # macOS Steam VR Link frontend (WIP)

Beat Saber is working on macOS and visionOS with minor graphical issues, Steam VR Link and improving generalizability/build tooling is still WIP.

联系我们 contact @ memedata.com