跳转至

Android

依赖项

仅限 Windows - 额外依赖项

  • Visual Studio 2022 Community - 确保在安装程序中选择“使用 C++ 的桌面开发”支持组件。如果已安装,请确保更新到最新版本。
  • Vulkan SDK - 确保选择最新的 SDK。
  • 在 .ci\windows\install-vulkan-sdk.ps1 中提供了一个用于安装最新 SDK 的便捷脚本。

使用 Git 克隆 Eden

git clone --recursive https://git.eden-emu.dev/eden-emu/eden.git

Eden 默认会被克隆到:

  • 在 Windows 上:C:\Users\<user-name>\eden
  • 在 Linux 和 macOS 上:~/eden

构建

  1. 启动 Android Studio,在启动对话框中选择 Open。
  2. 导航到 eden/src/android 目录,然后点击 OK。
  3. 在 Build > Select Build Variant 中,选择 release 或 relWithDebInfo 作为“Active build variant”。
  4. 使用 Build > Make Project 构建项目,或使用 Run > Run 'app' 在 Android 设备上运行。

使用终端构建

  1. 从 Android Studio 下载 SDK 和 NDK。
  2. 导航到 SDK 和 NDK 路径。
  3. 然后在终端中设置 ANDROID_SDK_ROOT 和 ANDROID_NDK_ROOT: export ANDROID_SDK_ROOT=path/to/sdk export ANDROID_NDK_ROOT=path/to/ndk.
  4. 导航到 eden/src/android。
  5. 然后使用 ./gradlew assembleRelWithDebInfo 构建。
  6. 要构建优化版本,请使用 ./gradlew assembleGenshinSpoofRelWithDebInfo。
  7. 你可以通过 -PYUZU_ANDROID_ARGS="-D..." 向 cmake 传递额外变量。

请记得安装 Java SDK(如果尚未安装)。在 Debian 及类似系统上,可以通过 sudo apt install openjdk-17-jdk 完成安装。

脚本

在 .ci/android/build.sh 中提供了一个便捷的构建脚本。在 Windows 上,必须在 Git Bash 或 MSYS2 中运行。该脚本提供以下选项:

Usage: build.sh [-c|--chromeos] [-t|--target FLAVOR] [-b|--build-type BUILD_TYPE]
                [-h|--help] [-r|--release] [extra options]

Build script for Android.
Associated variables can be set outside the script,
and will apply both to this script and the packaging script.
bool values are "true" or "false"

Options:
    -c, --chromeos          Build for ChromeOS (x86_64) (variable: CHROMEOS, bool)
                            Default: false
    -r, --release           Enable update checker. If set, sets the DEVEL bool variable to false.
                            By default, DEVEL is true.
    -t, --target <FLAVOR>   Build flavor (variable: TARGET)
                            Valid values are: legacy, optimized, standard
                            Default: standard
    -b, --build-type <TYPE> Build type (variable: TYPE)
                            Valid values are: Release, RelWithDebInfo, Debug
                            Default: Debug

Extra arguments are passed to CMake (e.g. -DCMAKE_OPTION_NAME=VALUE)
Set the CCACHE variable to "true" to enable build caching.
The APK and AAB will be output into "artifacts".

示例:

  • 构建带更新检查器的 legacy release:
  • .ci/android/build.sh -r -t legacy
  • 构建适用于手机的、不带更新检查器的 standard release(含调试信息):
  • .ci/android/build.sh -b RelWithDebInfo
  • 构建适用于 ChromeOS 的带更新检查器的 optimized release:
  • .ci/android/build.sh -c -r -t optimized

其他资源

https://developer.android.com/studio/intro

本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 eg/Eglantine