Skip to content
Tauri 中文网

Google Play

Google Play 是 Google 维护的 Android 应用分发服务。

🌐 Google Play is the Android app distribution service maintained by Google.

本指南涵盖了在 Google Play 上发布你的 Android 应用的要求。

🌐 This guide covers the requirements for publishing your Android app on Google Play.

🌐 Requirements

要在 Play 商店分发 Android 应用,你必须创建一个 Play Console 开发者账户。

🌐 To distribute Android apps in the Play Store you must create a Play Console developer account.

此外,你必须设置[代码签名]。

🌐 Additionally, you must setup code signing.

有关更多信息,请参见[发布清单]。

🌐 See the release checklist for more information.

🌐 Changing App Icon

在运行 tauri android init 设置 Android Studio 项目之后,你可以使用 tauri icon 命令来更新应用图标。

🌐 After running tauri android init to setup the Android Studio project, you can use the tauri icon command to update the app icons.

npm run tauri icon /path/to/app-icon.png

🌐 Setting up

一旦你创建了 Play 控制台开发者账户,你需要在 Google [Play 控制台] 网站上注册你的应用。它会引导你完成所有必要的表格和设置任务。

🌐 Once you’ve created a Play Console developer account, you need to register your app on the Google Play Console website. It will guide you through all the required forms and setup tasks.

🌐 Build

你可以通过运行以下命令构建 Android App Bundle (AAB) 以上传到 Google Play:

🌐 You can build an Android App Bundle (AAB) to upload to Google Play by running the following command:

npm run tauri android build -- --aab

Tauri 从 tauri.conf.json > version (versionCode = major*1000000 + minor*1000 + patch) 中定义的值获取版本代码。如果你需要不同的版本代码方案,例如顺序代码,你可以在 [tauri.conf.json > bundle > android > versionCode] 配置中设置自定义版本代码:

🌐 Tauri derives the version code from the value defined in tauri.conf.json > version (versionCode = major*1000000 + minor*1000 + patch). You can set a custom version code in the [tauri.conf.json > bundle > android > versionCode] configuration if you need a different version code scheme e.g. sequential codes:

tauri.conf.json
{
"bundle": {
"android": {
"versionCode": 100
}
}
}

🌐 Build APKs

AAB 格式是推荐上传到 Google Play 的应用包文件,但也可以生成可用于测试或在商店外部分发的 APK。要为你的应用编译 APK,可以使用 --apk 参数:

🌐 The AAB format is the recommended bundle file to upload to Google Play, but it is also possible to generate APKs that can be used for testing or distribution outside the store. To compile APKs for your app you can use the --apk argument:

npm run tauri android build -- --apk

🌐 Architecture selection

默认情况下,Tauri 会为所有支持的架构(aarch64、armv7、i686 和 x86_64)构建你的应用。要仅为部分目标编译,你可以使用 --target 参数:

🌐 By default Tauri builds your app for all supported architectures (aarch64, armv7, i686 and x86_64). To only compile for a subset of targets, you can use the --target argument:

npm run tauri android build -- --aab --target aarch64 --target armv7

🌐 Separate bundles per architecture

默认情况下,生成的 AAB 和 APK 是通用的,包含所有支持的目标。 要为每个目标生成单独的包,请使用 --split-per-abi 参数。

🌐 By default the generated AAB and APK is universal, containing all supported targets. To generate individual bundles per target, use the --split-per-abi argument.

npm run tauri android build -- --apk --split-per-abi

🌐 Changing the minimum supported Android version

Tauri 应用支持的最低 Android 版本为 Android 7.0(代号 Nougat,SDK 24)。

🌐 The minimum supported Android version for Tauri apps is Android 7.0 (codename Nougat, SDK 24).

有一些技术可以在仍支持旧系统的同时使用更新的 Android API。请参阅 Android 文档 获取更多信息。

🌐 There are some techniques to use newer Android APIs while still supporting older systems. See the Android documentation for more information.

如果你的应用必须在更新的 Android 版本上运行,你可以配置 [tauri.conf.json > bundle > android > minSdkVersion]:

🌐 If your app must execute on a newer Android version, you can configure [tauri.conf.json > bundle > android > minSdkVersion]:

tauri.conf.json
{
"bundle": {
"android": {
"minSdkVersion": 28
}
}
}

🌐 Upload

在构建你的应用并生成 Android App Bundle 文件后,该文件可以在 gen/android/app/build/outputs/bundle/universalRelease/app-universal-release.aab 中找到,你现在可以创建一个新版本并在 Google Play 控制台上传它。

🌐 After building your app and generating the Android App Bundle file, which can be found in gen/android/app/build/outputs/bundle/universalRelease/app-universal-release.aab, you can now create a new release and upload it in the Google Play Console.

第一次上传必须在网站上手动进行,以便它可以验证你的应用签名和打包标识符。Tauri 目前没有提供自动创建 Android 版本的方式,这必须利用 Google Play 开发者 API,但这是一个正在进行中的工作。

🌐 The first upload must be made manually in the website so it can verify your app signature and bundle identifier. Tauri currently does not offer a way to automate the process of creating Android releases, which must leverage the Google Play Developer API, but it is a work in progress.


Tauri 中文网 - 粤ICP备13048890号
Nodejs.cn 旗下网站