小辛的互联网作坊

在 Fedora 38 上安装 Waydroid

2023-05-17
Linux
fedora
waydroid
linux
最后更新:2024-05-03
5分钟
898字

Waydroid 介绍

  • Waydroid 是一种基于容器的、能在常规的 GNU/Linux 系统上启动完整 Android 系统的方法。
  • Waydroid 不支持 NVIDIA 显卡(tegra 除外),需要运行在 Wayland 显示服务器下。
  • Waydroid 基于 LineageOS。

安装环境

操作系统: Fedora 38 硬件配置: Intel ALder Lake I5-12500H 桌面环境: Gnome 44 Wayland 内核版本: 6.2.15-300.fc38.x86_64

安装

Gnome 44 默认显示服务是 Wayland,如需切换注销选择显示服务登录。

命令行安装:

Terminal window
1
sudo dnf install waydroid
2
3
sudo systemctl enable --now waydroid-container

安装完成之后打开 waydroid 程序,在 OTA 文本框填入以下链接:

System OTA: https://ota.waydro.id/system Vendor OTA: https://ota.waydro.id/vendor

然后选择是否需要安装 OPENGAPPS ,点击下载按钮,等待镜像下载完成。 镜像下载完成之后会自动安装,镜像初始化完成后好像 waydroid 会自动启动(这里我忘记了。。。)

Waydroid 命令与使用

启动容器

Terminal window
1
sudo waydroid container start

开启 Waydroid

Terminal window
1
waydroid session start

全屏模式

Terminal window
1
waydroid show-full-ui

多窗口模式

Terminal window
1
# 开启
2
waydroid prop set persist.waydroid.multi_windows true
3
# 关闭
4
waydroid prop set persist.waydroid.multi_windows false
5
6
sudo systemctl restart waydroid-container

设置宽高度

Terminal window
1
waydroid prop set persist.waydroid.width 0-9999 (int) Used for user to override desired resolution
2
waydroid prop set persist.waydroid.height 0-9999 (int) Used for user to override desired resolution

Other Waydroid Prop Options

Terminal window
1
waydroid prop set persist.waydroid.cursor_on_subsurface true/false (bool) Workaround for showing the cursor in multi_windows mode on some compositors
2
waydroid prop set persist.waydroid.invert_colors true/false (bool) Swaps the color space from RGBA to BGRA (only works with our patched mutter so far)
3
waydroid prop set persist.waydroid.height_padding 0-9999 (int) Adjust height padding
4
waydroid prop set persist.waydroid.width_padding 0-9999 (int) Adjust width padding
5
waydroid prop set persist.waydroid.suspend true/false (bool, default: true on kernel 4.9 and later) Let the Waydroid container sleep (after the display timeout) when no apps are active
6
waydroid prop set persist.waydroid.uevent true/false (bool, default: false) Allow android direct access to hotplugged devices
7
Modify app behaviour
8
waydroid prop set persist.waydroid.fake_touch (string, 91 character limit) Comma separated list of package names for which mouse inputs should be interpreted as touch inputs instead. Supports wildcards with *. For example, set this to "com.rovio.*" to match all games by Rovio.
9
waydroid prop set persist.waydroid.fake_wifi (string, 91 character limit) Comma separated list of package names for which the system will always appear as if connected to wifi. Supports wildcards with *. For example, set this to "com.gameloft.*" to match all games by Gameloft.

安装应用

Terminal window
1
waydroid app install xxx.apk
2
3
#or
4
usage: waydroid app [-h] {install,remove,launch,intent,list} ...
5
6
options:
7
-h, --help show this help message and exit
8
9
subaction:
10
{install,remove,launch,intent,list}
11
install push a single package to the container and install it
12
remove remove single app package from the container
13
launch start single application
14
intent start single application
15
list list installed applications

安装自定义镜像

将下载好的镜像放入目录:/usr/share/waydroid-extra/images/,然后运行:

Terminal window
1
waydroid init -f

使用 adb 连接调试

使用命令:

Terminal window
1
waydroid status

显示如下:

1
Session: RUNNING
2
Container: RUNNING
3
Vendor type: MAINLINE
4
IP address: 192.168.240.112
5
Session user: encorexin(1000)
6
Wayland display: wayland-0

然后使用命令链接:

Terminal window
1
abd connect <ip>:5555

设置共享目录

Terminal window
1
sudo mount --bind ~/Documents ~/.local/share/waydroid/data/media/0/Documents
2
sudo mount --bind ~/Downloads ~/.local/share/waydroid/data/media/0/Download
3
sudo mount --bind ~/Music ~/.local/share/waydroid/data/media/0/Music
4
sudo mount --bind ~/Pictures ~/.local/share/waydroid/data/media/0/Pictures
5
sudo mount --bind ~/Videos ~/.local/share/waydroid/data/media/0/Movies

使用脚本安装 Waydroid

项目主页:https://github.com/ayasa520/waydroid_script

安装脚本

Terminal window
1
sudo dnf install lzip
2
3
git clone https://github.com/ayasa520/waydroid_script.git
4
5
cd waydroid_script
6
7
sudo python3 -m pip install -r requirements.txt

使用

Terminal window
1
sudo python3 main.py

选择需要安装的 Android 版本 default

选择需要操作 default

选择需要安装的应用 default

如果之前已经安装过 waydroid 了只需要安装后面的应用就行。

获取设备 id 并注册给谷歌

使用命令进入 android shell:

Terminal window
1
sudo waydroid shell
2
ANDROID_RUNTIME_ROOT=/apex/com.android.runtime ANDROID_DATA=/data ANDROID_TZDATA_ROOT=/apex/com.android.tzdata ANDROID_I18N_ROOT=/apex/com.android.i18n sqlite3 /data/data/com.google.android.gsf/databases/gservices.db "select * from main where name = \"android_id\";"

然后会返回一段数据:android_id|* 星号为设备 id,是一串数字。

进入网址:https://www.google.com/android/uncertified,登录 Google 账号,将设备 id 复制到文本框内,点击注册等待半个小时然后重启 waydroid 就能在 waydroid 里面登录 Google Play 了。(需要将 waydroid 设备连接一次网络才能获取到设备 id,否则返回的内容为空。)

使用脚本获取:

Terminal window
1
sudo python3 main.py certified

至此,安装完成。

default

删除 Waydroid

Terminal window
1
sudo dnf remove waydroid
2
3
sudo rm -rf /usr/bin/waydroid /var/lib/waydroid /home/.waydroid ~/waydroid ~/.share/waydroid ~/.local/share/applications/*aydroid* ~/.local/share/waydroid

参考资料

本文标题:在 Fedora 38 上安装 Waydroid
文章作者:Encore Xin
发布时间:2023-05-17
版权声明:本作品采用 「署名-非商业性使用-相同方式共享 4.0 国际」许可协议进行许可