在 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 生态系统提供了一个稳固的基础。

一款能够让 Apple Vision Pro 运行 Android ARM64 VR APK 的工具发布后,在 Hacker News 上引发了关于苹果封闭生态系统的激烈争论。 该技术的支持者将其视为“极客社区”的胜利,认为苹果限制性的软件政策——特别是强制开发者使用 macOS 和 Xcode——对用户并不友好。批评者指出,苹果刻意限制其设备是为了维持“围墙花园”,这限制了用户自由,并迫使用户依赖其专有硬件。 相反,苹果的捍卫者认为,该公司对打磨完善、安全且简化体验的关注是其核心优势,而非缺陷。许多用户更倾向于这种“家电化”模式,并指出这降低了对技术支持的需求,且相比竞争对手提供了更卓越的硬件可靠性。 虽然一些参与者认为该平台的局限性是为了获取利润而人为设置的护城河,但另一些人则认为苹果的主要目标是为非技术用户提供无缝体验。这场讨论最终反映出,在那些优先考虑用户自由和开放平台的人,与那些重视封闭集成生态系统的一致性和简洁性的人之间,存在着更广泛且持续的紧张关系。
相关文章

原文

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