全面指南:掌握 Android App Bundle 的使用技巧(全面掌握的英文)(全方位的指导)

访客 167 0

Google has recently unveiled a new app publishing format called Android App Bundle (.aab extension) on the play console, which has now become the official publishing format. This innovative format was first introduced during Google I/O 2018 and starting from the second half of 2021, all newly submitted apps on the play console must utilize this format instead of the traditional Android Package (.apk extension).

Google在播放控制台上推出了一种新的应用程序发布格式,名为Android App Bundle (扩展名为.aab),现已成为官方发布格式。该格式是在2018年的Google I/O大会上引入的,并且从2021年下半年开始,所有提交到游戏机控制台的新应用都必须使用此格式,而不是传统的Android Package(.apk扩展名)。

什么是Android App Bundle? (What is Android App Bundle ?)

An Android App Bundle is a publishing format that encompasses all the compiled code and resources of your app, while delegating APK generation and signing tasks to Google Play.

Android应用程序捆绑包是一种发布格式,其中包含您应用程序的所有已编译代码和资源,并将APK生成和对Google Play的签名推迟至后期。”

Google Play利用您的应用程序包生成和提供针对每个设备配置进行优化的APK文件,因此只会下载运行您的应用程序所需的特定设备所需的代码和资源。您不再需要构建、签名和管理多个APK文件以优化支持不同设备,用户可以获得更小、更优化的下载文件。

通过使用您的应用捆绑包,Google Play能够为每种设备配置生成并提供经过优化的APK文件。这意味着只有特定设备所需的代码和资源才会被下载以运行您的应用程序。这样一来,您就不再需要构建、签名和管理多个APK文件来优化对不同设备的支持了。此外,用户还可以获得更小、更加优化的下载体验。

It distinguishes itself from APK by not allowing direct deployment and usage on a device. Instead, it serves as a publishing format that encompasses all the compiled code and resources of your app within a single build artifact.

与APK不同的是,您无法直接将其部署到设备上并使用。相反,它是一种发布格式,其中包含了应用程序的所有已编译代码和资源,并且以单个构建工件的形式存在。

Android App Bundle的优势 (Advantage of Android App Bundle)

  • 更小的应用程序大小:Google Play会自动将apk文件拆分为多个针对每个设备配置进行优化的apk文件。这意味着用户可以享受到更小的应用程序下载,而无需为其他设备所需的未使用代码和资源付出代价。平均而言,使用应用程序包发布的应用程序大小要减小20%。

    更小的应用尺寸:Google Play会自动将APK拆分为多个经过优化的APK,以适配不同设备配置。这意味着用户可以下载较小的应用程序,无需占用其他设备不需要的代码和资源。平均而言,通过应用捆绑发布的应用大小可减少20%。

  • Customized Feature Delivery: With this feature, you have the ability to tailor the user experience by allowing them to download and install the app first. Subsequently, you can prompt users to download specific features at a later stage. For instance, a gaming application may request users to install new levels, while a camera app might ask them to download additional filters.

    自定义功能交付:使用此功能,您可以使用户首先下载并安装该应用程序。 然后,您以后可以要求用户下载特定功能。 例如,游戏可能要求安装新关卡,或者相机应用程序要求下载滤镜。

  • Say goodbye to the hassle of managing multiple APKs: In the past, developers had to juggle multiple APKs for the same app, each with different version codes but the same package name, in order to create optimized apps. This process was arduous and time-consuming, particularly for those who were new to Android development. However, thanks to android app bundles, Google Play now takes care of all this complexity on your behalf. You can now breathe easy and focus on what matters most.

    减轻管理多个APK的负担以前,要构建优化的应用程序,开发人员需要使用不同的版本代码和相同的包名称来管理同一应用程序的多个apk。 处理这种情况非常困难且耗时(特别是如果您是Android的初学者或中级)。 但是,通过使用android应用程序捆绑包,这一切都由Google Play管理,您无需担心。

In addition, it boasts various other benefits such as streamlined app releases, accelerated build times, and the added advantage of providing Google Play Instant experiences.

它还拥有其他诸多优势,包括高效的应用发布、更短的构建时间,以及提供Google Play Instant体验。

建立Android应用程式套件 (Building an Android App Bundle)

You can access this feature on Android Studio 3.2 or newer, Unity 2018.3 & 2017.4.17, and Cocos Creator 2.0.9 or any subsequent version.

此功能可在Android Studio 3.2或更高版本、Unity 2018.3及2017.4.17以及Cocos Creator 2.0.9或更高版本中使用。

  • To begin with, add the provided code to the android{} block in your build.gradle(Module:app).

    首先,在android {}块的build.gradle(Module:app)中包含以下代码

在此之后,转到“构建 > 构建 Bundle/APK”并选择“构建 Bundle”。

接下来,您需要导航到“Build > Build Bundle(s)/APK(s)”选项,并选择“Build Bundle(s)”。

全面指南:掌握 Android App Bundle 的使用技巧(全面掌握的英文)(全方位的指导)-第1张图片-谷歌商店上架

这将生成一个名为app-debug.aab的文件(Android应用程序包使用.aab扩展名)。

生成的文件将是一个名为app-debug.aab的Android应用程序捆绑包(使用.aab扩展名)。

不同类型的拆分apk: (Different types of Split apks :)

在Android 5.0(API级别21)及更高版本中,为提供优化的应用程序服务,分割APK机制是一个基本组成部分。分割APK与常规APK非常相似——它们包含编译的DEX字节码、资源和Android清单。然而,Android平台能够将多个已安装的分割APK视为一个应用程序。

在Android 5.0(API级别21)及更高版本上,服务优化应用程序的基本组成部分是拆分APK机制。 拆分的APK与常规的APK非常相似,它们包含已编译的DEX字节码、资源和Android清单。 然而,在Android平台上,多个已安装的拆分APK可以被视为一个应用程序。

  • 基础APK:这个APK包含了所有其他分割APK可以访问的代码和资源,并为您的应用程序提供基本功能。当用户请求下载您的应用程序时,首先下载并安装此APK。

    基础APK:该APK包含了所有其他拆分APK所需的代码和资源,为您的应用程序提供基本功能。当用户请求下载您的应用程序时,首先会下载并安装此基础APK。

  • 配置APK:每个配置APK都包含特定屏幕密度、CPU架构或语言的本地库和资源。当用户下载您的应用时,他们的设备只会下载并安装针对其设备目标的配置APK。每个配置APK都是基本APK或功能模块APK的依赖项。也就是说,它们与提供代码和资源的APK一起被下载和安装。

    APK配置:每个APK都包含适用于特定屏幕密度、CPU体系结构或语言的本地库和资源。当用户下载您的应用时,他们的设备只会下载并安装与其设备配置相匹配的APK。每个配置APK都是基本APK或功能模块APK所依赖的组成部分。换句话说,它们与提供代码和资源的APK一起被下载并安装。

  • 特性模块 APK:每个 APK 都包含了你使用特性模块进行模块化的应用功能的代码和资源。然后,你可以自定义该特性在设备上下载的方式和时间。

    功能模块APK:每个APK都包含您使用功能模块进行模块化的应用功能的代码和资源。 然后,您可以自定义如何以及何时将该功能下载到设备上。

全面指南:掌握 Android App Bundle 的使用技巧(全面掌握的英文)(全方位的指导)-第2张图片-谷歌商店上架 Dependency tree for an app served using split APKs (image credit : developer.android.com) 使用拆分APK投放的应用的依赖树(图片来源:developer.android.com)

重要提示:对于运行Android 4.4(API级别20)及以下版本的设备,Google Play会自动提供一个针对设备配置进行优化的单个APK文件。

请注意:对于运行Android 4.4(API级别20)及更低版本的设备,Google Play会自动提供经过优化的单个APK,以适应不同设备配置。

使用Google Play控制台测试应用(内部测试跟踪): (Testing the app with Google Play Console (Internal Test Track) :)

To upload an app on Play Console, it is necessary to sign the apk. Therefore, please adhere to the following steps:

为了在Play控制台上上传应用程序,您需要一个以apk开头的文件。因此,请按照以下步骤进行操作:

  • 从菜单栏中选择构建 > 生成已签名的Bundle/APK。在生成已签名的Bundle或APK对话框中,选择Android应用程序包并点击下一步

    请按照以下步骤操作:在菜单栏中点击“构建”,然后选择“生成签名包/ APK”。接下来,在弹出的对话框中,选择“Android应用包”,并点击“下一步”。

  • In the Module dropdown menu, select the base module of the app you want to generate an app bundle for.

    在“模块”下拉菜单中,选择您想要为其生成应用程序捆绑包的应用程序的基本模块。

  • Provide information for an existing key and keystore, or create a new one. This is the same type of key and keystore information you provide when building a signed APK.

    您可以获取现有密钥和密钥库的相关信息,或者创建一个全新的密钥和密钥库。这与您在构建APK签名时所提供的密钥和密钥库信息类型相同。

  • If you want Android Studio to also save your signing key as an encrypted file, check the box next to Export encrypted key. To be able to upload your app bundle and take advantage of Dynamic Delivery, you need to upload this encrypted file to the Play Console and enroll in app signing by Google Play.

    如果您想将Android Studio中的签名密钥保存为加密文件,只需勾选“导出加密密钥”旁边的框即可。为了能够上传您的应用程序包并使用动态交付功能,您需要将此加密文件上传到Play控制台,并通过Google Play进行应用程序签名注册。

  • Click the Next button and specify a destination folder for your app bundle. Choose the desired build type and flavors to generate app bundles for.

    点击下一步,后,您需要选择一个目标文件夹来打包您的应用程序。在这里,您可以选择生成应用程序捆绑包的构建类型风味

  • 点击完成

    点击完成

Now , we can upload this app bundle on play console. To upload on Play Console (Internal Test Track) follow this tutorial.

现在,我们可以将该应用程序捆绑包上传至游戏机。如果您想在Play控制台(内部测试跟踪)上进行上传,请按照本教程的指引操作。

使用bundletool测试应用程序包: (Testing app bundle using bundletool :)

使用bundletool的build-apks命令,可以为您的应用程序从应用程序包生成适用于所有设备配置的APK集合。

请使用bundletool build-apks命令,以生成支持您应用程序捆绑包中所有设备配置的APK集合。

Only two arguments are required for the command: $ bundletool build-apks --bundle= --output=      

只需要两个参数,

  • The path to the .aab file and,

    请提供更多上下文,以便我能够更好地理解并改写这段话。

    现在,您可以执行build-apks操作。

    警告:如果您不通过 --ks 标志传递密钥库,APK 文件将不会被签名,因此无法安装。请使用以下命令生成 APKs 文件:
    $ bundletool build-apks --bundle=/MyApp/my_app.aab --output=/MyApp/my_app.apks
    --ks=/MyApp/keystore

    如果要通过APK集部署应用程序,请使用install-apks命令,并指定APK集的路径。

    希望这篇文章能帮助你顺利使用 Android App Bundles。同时,你可以尝试使用以下命令来安装 APK 文件:bundletool install-apks --apks=/MyApp/my_app.apks

    希望本文能够帮助您深入了解Android应用程序捆绑包的相关知识。

    引用来源:https://medium.com/@mrudultora/android-app-bundle-complete-guide-69984d02f744 改写后的版本: 来源于Medium网站上的一篇文章,标题为《Android App Bundle完全指南》。

标签: 谷歌商店上架 设备 密钥

发表评论 (已有0条评论)

还木有评论哦,快来抢沙发吧~