使用Waydroid在Linux上运行x86_64的安卓软件
Dionysen

Windows有WSA,Linux有Waydroid,两者的性能损失之小都相当可观。

虽然两者目前都不够成熟,有许多需要改进之处,但还是非常好用的。

环境

image
$ uname -a
Linux dionysen-latitude7430 6.1.31-2-MANJARO #1 SMP PREEMPT_DYNAMIC Sun Jun 4 12:31:46 UTC 2023 x86_64 GNU/Linux

安装waydroid

yay -S waydroid
下载镜像,一般使用LineageOS,在[此处](https://sourceforge.net/projects/waydroid/)下载两个文件:

system.zipvendor.zip

下载完成后将.img文件解压到/usr/share/waydroid-extra/images目录下,文件夹若不存在则创建。

sudo waydroid init
sudo systemctl enable --now waydroid-container

此时应该可以正常使用了。

常用命令

确保 waydroid-container.service 正在运行,然后执行:

waydroid session start

Waydroid 会话现在已处于活动状态,这里有一些与 Waydroid 交互的实用命令:

启动 GUI:

waydroid show-full-ui

启动 shell:

waydroid shell

安装应用程序:

waydroid app install $path_to_apk

运行应用程序:

waydroid app launch $package-name #Can be retrieved with `waydroid app list`

image

image

注意,安装的安卓应用可能会显示在linux系统的应用中,但最好不要直接点击它来启动应用,而是使用命令行:

➜  ~ sudo systemctl status waydroid-container
● waydroid-container.service - Waydroid Container
Loaded: loaded (/usr/lib/systemd/system/waydroid-container.service; enable>
Active: active (running) since Wed 2023-07-05 01:02:16 CST; 3min 56s ago
Main PID: 574 (python3)
Tasks: 2 (limit: 9204)
Memory: 35.9M
CPU: 229ms
CGroup: /system.slice/waydroid-container.service
└─574 python3 /usr/bin/waydroid -w container start

7月 05 01:02:15 dionysen-latitude7430 systemd[1]: Starting Waydroid Container...
7月 05 01:02:16 dionysen-latitude7430 systemd[1]: Started Waydroid Container.
# 确保服务正在运行
waydroid session start
# 然后再去点击Waydroid的应用图标

另:由于系统对应的架构是x86_64,因此最好去一些网站下载此架构的应用,如appmirror(需梯子)。

Setting up a shared folder

User @wachidadinugroho has worked out the details on how to setup a shared folder to be used between Waydroid and your host filesystem.

Setting up a shared folder will allow the user to copy/paste files from the host and they appear inside waydroid/android. sudo mount --bind <source> ~/.local/share/waydroid/data/media/0/<target>

Then verify that the target folder exists:

sudo ls ~/.local/share/waydroid/data/media/0/ Examples:

sudo mount --bind ~/Documents ~/.local/share/waydroid/data/media/0/Documents
sudo mount --bind ~/Downloads ~/.local/share/waydroid/data/media/0/Download
sudo mount --bind ~/Music ~/.local/share/waydroid/data/media/0/Music
sudo mount --bind ~/Pictures ~/.local/share/waydroid/data/media/0/Pictures
sudo mount --bind ~/Videos ~/.local/share/waydroid/data/media/0/Movies

You can also make your own custom mount point to cater to your needs.

显示评论