「Anbox」の版間の差分

提供: ArchWiki
ナビゲーションに移動 検索に移動
(序文を英語版を元に差し替え)
(→‎インストール: == Prerequisite == を追加)
6行目: 6行目:
 
{{Related articles end}}
 
{{Related articles end}}
 
Anbox は GNU/Linux ディストリビューションで Android を実行するための [[Linux_Containers|コンテナベース]] のソフトウェアです。
 
Anbox は GNU/Linux ディストリビューションで Android を実行するための [[Linux_Containers|コンテナベース]] のソフトウェアです。
  +
  +
== Prerequisite ==
  +
{{Note|The dkms modules do not work on kernels ≥5.7 anymore. Follow the instructions below instead. For older kernels see [[#Old kernels|Old kernels]].}}
  +
  +
You need to run a kernel which comes with the ashmem and binder modules. They are not part of Arch Linux's default kernel ({{Pkg|linux}}), thus you need to install a kernel which ships these modules.
  +
  +
You might also need to configure your bootloader to use a different kernel.
  +
  +
You have multiple options:
  +
  +
=== Using Linux-Zen ===
  +
  +
The {{Pkg|linux-zen}} kernel includes the necessary modules. This might be the most comfortable way, as you do not have to compile the kernel (which takes a long time) and will receive updated versions regularly.
  +
  +
=== Building a kernel ===
  +
  +
Alternatively, you can recompile the {{Pkg|linux}} kernel — or other kernel packages (>=5.7) — with the necessary options. Please read [[Kernel#Compilation]] and [[#Necessary config options|Necessary config options]] below.
  +
  +
You can also build a kernel package that already includes the specific patches from [[AUR]], see [https://aur.archlinux.org/packages/?K=linux+anbox  AUR search "linux+anbox"].
  +
  +
==== Necessary config options ====
  +
  +
Modules can either be compiled into the kernel ({{ic|y}}), into modules ({{ic|m}}), or not at all ({{ic|n}}). Also, not all combinations in the config are possible, and some options will require other options.
  +
  +
The config options below will compile ashmem and binder as modules, while the last option specifies that there will be three devices created in the {{ic|/dev/}} directory, when the binder module is loaded.
  +
  +
{{bc|1=
  +
CONFIG_ASHMEM=m
  +
CONFIG_ANDROID=y
  +
CONFIG_ANDROID_BINDER_IPC=m
  +
CONFIG_ANDROID_BINDERFS=n
  +
CONFIG_ANDROID_BINDER_DEVICES="binder,hwbinder,vndbinder"
  +
}}
  +
  +
When building a kernel from the AUR, one can do it with these steps:
  +
  +
# run {{ic|makepkg --nobuild}}, which will download the sources, verify and extract them and run the {{ic|prepare()}} function.
  +
# edit the {{ic|.config}} file (with the dot in the filename), which is located at the base of the kernel directory.
  +
# at the end of the {{ic|prepare()}} function was probably a command which regenerates the makefiles with information from the config, possibly {{ic|make olddefconfig}}. Move that to the {{ic|build()}} function, or execute it yourself.
  +
# run {{ic|makepkg --noextract}}, which will continue from the place where {{ic|makepkg --nobuild}} stopped.
  +
  +
==== config using binderfs ====
  +
  +
Not everybody was happy with the binder module in Linux. To address the issues, binderfs was created. One has to choose between the old and the new way when compiling the kernel. With the options below one will use binderfs instead.
  +
  +
With the kernel sources comes also a simple script to set config options. It will not do dependency checks, just like when editing the config by hand. When being in the same directory where the {{ic|.config}} file lies, one can execute the following commands:
  +
  +
{{bc|
  +
scripts/config --module CONFIG_ASHMEM
  +
scripts/config --enable CONFIG_ANDROID
  +
scripts/config --enable CONFIG_ANDROID_BINDER_IPC
  +
scripts/config --enable CONFIG_ANDROID_BINDERFS
  +
scripts/config --set-str CONFIG_ANDROID_BINDER_DEVICES ""
  +
}}
  +
  +
This script is handy when building a kernel from the AUR, as it is enough to insert these lines at the right place in the PKGBUILD.
  +
  +
=== Booting the new kernel ===
  +
  +
Please refer to the wiki page of your bootloader, to find out, how to boot with the new kernel. Booting into a newer kernel (version) is one of the few occasions when you have to reboot a Linux system. You should do that before starting Anbox.
   
 
== インストール ==
 
== インストール ==

2021年7月6日 (火) 10:47時点における版

関連記事

Anbox は GNU/Linux ディストリビューションで Android を実行するための コンテナベース のソフトウェアです。

Prerequisite

ノート: The dkms modules do not work on kernels ≥5.7 anymore. Follow the instructions below instead. For older kernels see Old kernels.

​ You need to run a kernel which comes with the ashmem and binder modules. They are not part of Arch Linux's default kernel (linux), thus you need to install a kernel which ships these modules. ​ You might also need to configure your bootloader to use a different kernel. ​ You have multiple options: ​

Using Linux-Zen

​ The linux-zen kernel includes the necessary modules. This might be the most comfortable way, as you do not have to compile the kernel (which takes a long time) and will receive updated versions regularly. ​

Building a kernel

​ Alternatively, you can recompile the linux kernel — or other kernel packages (>=5.7) — with the necessary options. Please read Kernel#Compilation and Necessary config options below. ​ You can also build a kernel package that already includes the specific patches from AUR, see AUR search "linux+anbox". ​

Necessary config options

​ Modules can either be compiled into the kernel (y), into modules (m), or not at all (n). Also, not all combinations in the config are possible, and some options will require other options. ​ The config options below will compile ashmem and binder as modules, while the last option specifies that there will be three devices created in the /dev/ directory, when the binder module is loaded. ​

CONFIG_ASHMEM=m 
CONFIG_ANDROID=y
CONFIG_ANDROID_BINDER_IPC=m
CONFIG_ANDROID_BINDERFS=n
CONFIG_ANDROID_BINDER_DEVICES="binder,hwbinder,vndbinder"

​ When building a kernel from the AUR, one can do it with these steps: ​

  1. run makepkg --nobuild, which will download the sources, verify and extract them and run the prepare() function.
  2. edit the .config file (with the dot in the filename), which is located at the base of the kernel directory.
  3. at the end of the prepare() function was probably a command which regenerates the makefiles with information from the config, possibly make olddefconfig. Move that to the build() function, or execute it yourself.
  4. run makepkg --noextract, which will continue from the place where makepkg --nobuild stopped.

config using binderfs

​ Not everybody was happy with the binder module in Linux. To address the issues, binderfs was created. One has to choose between the old and the new way when compiling the kernel. With the options below one will use binderfs instead. ​ With the kernel sources comes also a simple script to set config options. It will not do dependency checks, just like when editing the config by hand. When being in the same directory where the .config file lies, one can execute the following commands: ​

scripts/config --module  CONFIG_ASHMEM
scripts/config --enable  CONFIG_ANDROID
scripts/config --enable  CONFIG_ANDROID_BINDER_IPC
scripts/config --enable  CONFIG_ANDROID_BINDERFS
scripts/config --set-str CONFIG_ANDROID_BINDER_DEVICES ""

​ This script is handy when building a kernel from the AUR, as it is enough to insert these lines at the right place in the PKGBUILD. ​

Booting the new kernel

​ Please refer to the wiki page of your bootloader, to find out, how to boot with the new kernel. Booting into a newer kernel (version) is one of the few occasions when you have to reboot a Linux system. You should do that before starting Anbox.

インストール

anbox-gitAUR, anbox-imageAUR (もしくは Google のアプリや houdini も使いたい場合は anbox-image-gappsAUR), anbox-modules-dkms-gitAUR[リンク切れ: パッケージが存在しません], anbox-bridgeAUR[リンク切れ: パッケージが存在しません] をインストールしてください。

最新の 5.1 カーネルでは anbox-modules-dkms-gitAUR[リンク切れ: パッケージが存在しません] の PKGBUILD にパッチ [1] を適用しないと必要な binder モジュールがコンパイルできません。

以下のサービスを起動有効化してください:

  • anbox-container-manager.service

DKMS モジュールを使うのにコンピュータを再起動したくない場合、手動でロードすることができます:

# modprobe ashmem_linux
# modprobe binder_linux

使用方法

anbox 内でネットワークを使えるようにするため anbox を起動する前に毎回 anbox-bridge を実行してください。

それから、デスクトップランチャーの Other カテゴリから android アプリケーションを実行できます。

adb を使ってデバッグしたい場合、android-tools をインストールしてください。

$ adb shell