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.
:::note 注意
Tauri 在后台使用 Android Studio 项目,因此任何用于构建和发布 Android 应用的官方做法也适用于你的应用。有关更多信息,请参阅 官方文档。
¥Tauri uses an Android Studio project under the hood, so any official practice for building and publishing Android apps also apply to your app. See the official documentation for more information.
:::
要求
¥Requirements
要在 Play Store 中分发 Android 应用,你必须创建一个 Play 控制台 开发者账户。
¥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
yarn tauri icon /path/to/app-icon.png
pnpm tauri icon /path/to/app-icon.png
deno task tauri icon /path/to/app-icon.png
cargo tauri icon /path/to/app-icon.png
设置
¥Setting up
创建 Play Console 开发者账户后,你需要在 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
yarn tauri android build --aab
pnpm tauri android build --aab
deno task tauri android build --aab
cargo 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:
{ "bundle": { "android": { "versionCode": 100 } }}
构建 APK
¥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
yarn tauri android build --apk
pnpm tauri android build --apk
deno task tauri android build --apk
cargo 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
yarn tauri android build --aab --target aarch64 --target armv7
pnpm tauri android build --aab --target aarch64 --target armv7
deno task tauri android build --aab --target aarch64 --target armv7
cargo 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.
:::note 注意
这仅适用于在 Google Play 之外进行测试或分发,因为它可以减小文件大小,但上传不太方便。Google Play 为你处理支持的架构。
¥This is only useful for testing or distribution outside Google Play, as it reduces the file size but is less convenient to upload. Google Play handles the supported architectures for you.
:::
npm run tauri android build -- --apk --split-per-abi
yarn tauri android build --apk --split-per-abi
pnpm tauri android build --apk --split-per-abi
deno task tauri android build --apk --split-per-abi
cargo tauri android build --apk --split-per-abi
更改支持的最低 Android 版本
¥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
]:
{ "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号