0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

x86のAOSPでArmのアプリを動かせるようにする(Android11)

Posted at

はじめに、この記事はwaydroid_scriptのソースを参考に書いています(waydroid_scriptでやっていることをaospでもできるようにしています)
https://github.com/casualsnek/waydroid_script

また、Android11と書いていますが、Android13でもおそらくできると思います
Android13の場合は適宜読み替えてください

1.まず、必要なファイルを以下からダウンロードしてください(dl_linksです)
https://github.com/casualsnek/waydroid_script/blob/main/stuff/ndk.py

それを作業ディレクトリに展開してください
以下のようになっているのが正しいです

$ls
ndk

2.-writable-systemのオプションをつけてemulatorを起動してください

3.以下のコードを実行します
コードは汚いですが正しく動くと思います...

import os
import subprocess


def init():
    subprocess.run(["adb", "remount"])
    subprocess.run(["adb", "shell", "mount", "-o", "rw,remount", "/system"])


def chown(path, uid, gid):
    subprocess.run(["adb", "shell", "chown", f"{uid}:{gid}", path])


def chmod(path, mode):
    subprocess.run(["adb", "shell", "chmod", f"{mode}", path])


def mkdir(path):
    subprocess.run(["adb", "shell", "mkdir", "-m", "777", "-p", path])


def push_file(src, dest):
    subprocess.run(["adb", "push", src, dest])


def get_dir(path):
    return "/".join(path.split("/")[:-1])


def write_build_prop():
    prop = """
ro.product.cpu.abilist=x86_64,x86,armeabi-v7a,armeabi,arm64-v8a
ro.product.cpu.abilist32=x86,armeabi-v7a,armeabi
ro.product.cpu.abilist64=x86_64,arm64-v8a
ro.dalvik.vm.native.bridge=libndk_translation.so
ro.enable.native.bridge.exec=1
ro.vendor.enable.native.bridge.exec=1
ro.vendor.enable.native.bridge.exec64=1
ro.ndk_translation.version=0.2.3
ro.dalvik.vm.isa.arm=x86
ro.dalvik.vm.isa.arm64=x86_64
"""
    command = f"echo '{prop}'  | tee -a /system/build.prop >> /system/vendor/build.prop"
    subprocess.run(["adb", "shell", command])


files = [
    "bin/arm",
    "bin/arm64",
    "bin/ndk_translation_program_runner_binfmt_misc",
    "bin/ndk_translation_program_runner_binfmt_misc_arm64",
    "etc/binfmt_misc",
    "etc/ld.config.arm.txt",
    "etc/ld.config.arm64.txt",
    "etc/init/ndk_translation.rc",
    "lib/arm",
    "lib64/arm64",
    "lib/libndk*",
    "lib64/libndk*",
]


init()

os.chdir(
    "./ndk/vendor_google_proprietary_ndk_translation-prebuilt-9324a8914b649b885dad6f2bfd14a67e5d1520bf/prebuilts"
)
for root, dirs, files in os.walk("."):
    for file in files:
        path = root + "/" + file
        dir = get_dir(path)
        mkdir("/system/" + dir)
        push_file(path, "/system/" + path)
        chown("/system/" + path, 0, 0)
        chmod("/system/" + path, "777")

write_build_prop()

4.再起動してx86のバイナリがないarmのアプリが正しく動くことを確認します

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?