Files
MaaAssistantArknights/docs/en-us/manual/device/linux.md
Loong 62ffdc73cb ci: use lychee to check dead links (#9675)
* ci: use lychee to check dead links

* ci: comment on PR when dead links are found

* docs: fix broken links
2024-07-17 15:26:17 +01:00

145 lines
6.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
order: 3
icon: teenyicons:linux-alt-solid
---
# Linux Emulator and Container
## Preparation
You can choose one of the following installation methods:
### Use maa-cli
[maa-cli](https://github.com/MaaAssistantArknights/maa-cli) is a simple CLI for MAA made with Rust. Please read installation and usage tutorials in [User Guide for CLI](../cli/).
### Use Wine
The MAA WPF GUI can currently be run using Wine.
#### Installation Steps
1. Go to the [.NET Release Page](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) to download and install the .NET **Desktop** Runtime for Windows.
2. Download MAA for Windows, unzip it and run `wine MAA.exe`.
::: info Note
You need to set the ADB path to [`adb.exe` for Windows](https://dl.google.com/android/repository/platform-tools-latest-windows.zip) in the connection settings.
If you need to connect to USB devices via ADB, please run `adb start-server` outside of Wine first, i.e. connect to the native ADB server via Wine.
:::
#### Use Linux native MaaCore (experimental feature)
Download the [MAA Wine Bridge](https://github.com/MaaAssistantArknights/MaaAssistantArknights/tree/dev/src/MaaWineBridge) source and build it, replace the Windows version with the generated `MaaCore.dll` (ELF file) in the same directory as the Linux native dynamic libraries (`libMaaCore.so` and dependencies).
Running `MAA.exe` through Wine will load the Linux native libraries.
::: info Note
To use Linux native MaaCore, you need to set the ADB path to Linux native ADB in the connection settings.
:::
#### Linux Desktop Integration (experimental feature)
Desktop integration provides native desktop notification support and the ability to map fontconfig font configurations to WPF.
Enable it by placing `MaaDesktopIntegration.so` generated by MAA Wine Bridge in the same directory as `MAA.exe`.
#### Known Issues
- Wine DirectWrite forces hinting to be enabled and does not pass DPI to FreeType, resulting in poor font display.
- When not using native desktop notifications, the popup notification will grab the system-wide mouse focus, making it impossible to operate other windows. This can be mitigated by enabling virtual desktop mode via `winecfg`, or disabling desktop notifications.
- Wine-staging users need to disable the `Hide Wine Version` option in `winecfg` in order for MAA to properly detect the Wine environment.
- Wine's Light theme causes some text colours in WPF to be abnormal, it is recommended to switch to no theme (Windows Classic theme) in `winecfg`.
- Wine uses the old XEmbed tray icon, which may not work properly under GNOME.
- Auto-update is not supported when using Linux native MaaCore (~~Updater: I think I should download a Windows version~~).
### Use Python
#### 1. Installing dynamic library
1. Download and extract `Linux library` in [MAA Website](https://maa.plus/), or install from linux software repository:
- AUR[maa-assistant-arknights](https://aur.archlinux.org/packages/maa-assistant-arknights), edit the script according to the post-install instruction.
- Nixpkgs: [maa-assistant-arknights](https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/by-name/ma/maa-assistant-arknights/package.nix)
2. Open `sample.py` in `./MAA-v{VERSION}-linux-{ARCH}/Python/`
> **Note**
> The precompiled version is built in a relatively new distro (Ubuntu 22.04), you may run into binary compatability problem, if libstdc++ in your environment is too old.
> Where you should reference to [Linux tutorial](../../develop/linux-tutorial.md), or run inside a container instead.
#### 2. `adb` Settings
1. Target to [`if asst.connect('adb.exe', '127.0.0.1:5554'):`](https://github.com/MaaAssistantArknights/MaaAssistantArknights/blob/722f0ddd4765715199a5dc90ea1bec2940322344/src/Python/sample.py#L48)
2. `adb` Tools Settings
- If you use `avd` in `Android Studio` as your emulator, it contains `adb` that you can use it directly. Just fill in your `adb` path in `adb.exe`, you can usually find it in `$HOME/Android/Sdk/platform-tools/` , eg.:
```python
if asst.connect("/home/foo/Android/Sdk/platform-tools/adb", "avd_ID"):
```
- If you use other emulators, you have to install `adb` first: `$ sudo apt install adb` and then fill in the path of adb or just fill in `adb` if you had put it into the `PATH` environment variable.
3. Emulator `adb` ID Settings
- You can use the adb tool directly: `$ ${adb_path} devices` , eg.:
```shell
$ /home/foo/Android/Sdk/platform-tools/adb devices
List of devices attached
emulator-5554 device
```
- `emulator-5554` that the terminal returns is the ID of emulator adb, replacing `127.0.0.1:5555` with it, eg.
```python
if asst.connect("/home/foo/Android/Sdk/platform-tools/adb", "emulator-5554"):
```
4. Now you can test: `$ python3 sample.py` , if return `连接成功` , you almost finish setting.
#### 3. Tasks Settings
Customizing tasks: Reference to [AsstAppendTask](../../protocol/integration.md#asstappendtask) and modify [`# 任务及参数请参考 docs/集成文档.md`](https://github.com/MaaAssistantArknights/MaaAssistantArknights/blob/722f0ddd4765715199a5dc90ea1bec2940322344/src/Python/sample.py#L54) section in `sample.py`.
## Emulator Supports
### ✅ [AVD](https://developer.android.com/studio/run/managing-avds)
Requests: Resolution should be 16:9 and above 720p
Recommendation: x86\_64 architecture (R - 30 - x86\_64 - Android 11.0) with `Linux x64 动态库` in MAA
### ⚠️ [Genymotion](https://www.genymotion.com/)
Native x86\_64 architecture in high version of Android, light weight but easy to crash when running Arknights.
We have not testing strictly, but adb functions and path have no error.
## Containerized Android
> **Note**
> The following solutions are likely to depend on special kernel modules, make sure to have them installed accordingly.
### ✅ [Waydroid](https://waydro.id/)
Need to reset the resolution to 16:9 (You can set it above 720P):
```shell
waydroid prop set persist.waydroid.width 1280
waydroid prop set persist.waydroid.height 720
```
After restarting, record `IP address` in `Setting` - `About phone` , fill `${IP address}:5555` to the adb IP address in `sample.py` .
If you are using amdgpu, `screencap` command may write messages to stderr, causing image decoding error.
Run `adb exec-out screencap | xxd | head` to check if there is something like `/vendor/etc/hwdata/amdgpu.ids: No such file...` in the output.
Modify screencap commands in `resource/config.json` from `adb exec-out screencap` to `adb exec-out 'screencap 2>/dev/null'` as a workaround.
### ✅ [redroid](https://github.com/remote-android/redroid-doc)
Arknights runs properly in Android 11 image. Do remember to expose port 5555 for adb.