android中两层选项卡_android中的可定制交付选项

android中两层选项卡

Android App Bundles solve some previous problems in Android development by providing a way for developers to create a single package from within Android Studio, and have custom APK files automatically generated by Google Play for each individual supported configuration. Besides, after introducing Android App Bundle, a number of developers have used this approach to optimize delivery. This essay aims to discuss some options for customizable delivery in Android development.

Android App Bundles为开发人员提供了一种从Android Studio内部创建单个程序包的方式,并通过Google Play为每个受支持的配置自动生成了自定义APK文件,从而解决了Android开发中的一些先前问题。 此外,在引入Android App Bundle之后,许多开发人员都使用这种方法来优化交付。 本文旨在讨论Android开发中可自定义交付的一些选项。

总览 (Overview)

Recently, after introducing Android App Bundle, a number of developers have used this approach to optimize delivery. This includes some of the most popular apps on Play like YouTube, and they observe incredible size changes, that range from around 10% to 60% decreases in comparison with delivering a normal APK. The introduction of the App bundle gives you an opportunity for utilizing new delivery features in Android, which would not have been possible in the past. By using App Bundle, we can build delivery that optimizes all aspects of your app serving from which part of the app to serve, to whom and when. Additionally, some customizable delivery options give you a chance to control of how your app is delivered. Some products can illustrates the concept of customizable delivery in Android at the moment that are mentioned as follows:

最近,在引入Android App Bundle之后,许多开发人员都使用这种方法来优化交付。 其中包括YouTube等Play上一些最受欢迎的应用,并且它们观察到了令人难以置信的大小变化,与提供普通APK相比,大小变化范围大约为10%到60%。 App捆绑包的引入为您提供了利用Android中新的交付功能的机会,而这在过去是不可能的。 通过使用App Bundle,我们可以构建交付,以优化您应用的各个方面,从哪个部分,何时向谁提供服务。 另外,一些可自定义的交付选项使您可以控制应用的交付方式。 某些产品目前可以说明Android中可自定义交付的概念,其中提到如下:

  1. In-app updates

    应用内更新
  2. Conditional Delivery

    有条件的交付
  3. On-demand delivery and Dynamic Feature

    按需交付和动态功能
  4. Asset delivery for games

    游戏资产交付

Android应用程式套件 (Android App Bundle)

As you know, the App bundle is a new publishing format that replaces the traditional monolithic APK; however, the App Bundle is not installed directly. In contrast, Google Play generates APKs optimized for specific devices from the single bundle upload. These APKs are much more smaller than a single APK. In addition, the single upload provides a much simpler developer experience than uploading multiple APKs. Therefore, the smaller download size is achieved by delivering just only the resources from the app that the specific devices need. By using App bundle, only the selected languages, densities, and CPU architectures are delivered. As a result, a smaller install space on the device and a faster download could be reached via this option. Studies has showed that the App Bundle causes 20% decrease in app size on average. This leads to faster downloads, which leads to an 11% in install successes due to fewer chances for failing the process of downloads. Besides, because less storage space is used, it causes a reduction in uninstalls. Thus, there are more than 80,000 apps have moved over to the App bundle at present. These Android apps are publishing a single bundle, and relying on Google Play to deliver smaller APKs to particular devices tailored for them.

如您所知,App捆绑包是一种新的发布格式,替代了传统的整体式APK。 但是,没有直接安装App Bundle。 相比之下,Google Play从单个捆绑包上传中生成针对特定设备优化的APK。 这些APK比单个APK小得多。 此外,与上传多个APK相比,单次上传提供的开发人员体验要简单得多。 因此,通过仅从特定设备需要的应用程序中交付资源即可实现较小的下载大小。 通过使用应用程序捆绑包,仅交付所选的语言,密度和CPU体系结构。 结果,通过此选项可以实现设备上较小的安装空间和更快的下载。 研究表明,App Bundle会使应用程序大小平均减少20%。 这将导致下载速度更快,由于减少了失败的下载过程的机会,因此安装成功率达到11%。 此外,由于使用了较少的存储空间,因此减少了卸载。 因此,目前有超过80,000个应用程序移至该App Bundle。 这些Android应用程序发布了一个捆绑包,并依靠Google Play将较小的APK交付给为其量身定制的特定设备。

An Android App Bundle is a file with the .aab file extension, which you upload to Google Play. In fact, App bundles are signed binaries, which organize your app’s code and resources into modules, as indicated in below figure:

Android App Bundle是带有.aab文件扩展名的文件,您可以将其上传到Google Play。 实际上,App捆绑包是签名的二进制文件,可将您的应用程序的代码和资源组织到模块中,如下图所示:

Image for post
Google Android developer documents Google Android开发人员文档的 Android App Bundle

应用内更新 (In-app updates)

Fundamentally, keeping your Android app up-to-date on your users’ devices, enables them to use advanced features of your app. Furthermore, users can benefit from performance enhancements and bug fixes appropriately. In essence, in-app updates is a Play Core library feature, which introduces an advanced request flow to active users to update your app immediately. In-app update approach works just only with devices running Android 5.0 or higher, and needs you to use Play Core library 1.5.0 or higher versions. Currently, in-app updates give you a way to trigger updates of your app directly from your app. This means it gives you control over the right contextual moment to start an update, when keeping the user in the app without any additional risks to users. Basically, in-app updates can classify in two flavors as below:

从根本上讲,让您的用户设备上的Android应用程序保持最新状态,使他们能够使用应用程序的高级功能。 此外,用户可以从性能增强和错误修复中受益。 本质上, 应用程序内更新是Play Core库的一项功能,它向活动用户引入了高级请求流,可以立即更新您的应用程序。 应用内更新方法仅适用于运行Android 5.0或更高版本的设备,并且需要您使用Play Core库 1.5.0或更高版本。 目前,应用内更新为您提供了一种直接从应用中触发应用更新的方法。 这意味着当您将用户保留在应用程序中时,它使您可以控制在适当的上下文时机开始更新,而不会给用户带来任何其他风险。 基本上,应用内更新可以分为以下两种类型:

1.Immediate: it triggers the updates right away, and it needs minimal integration, because Play manages User Experience during the update. In other words, a full screen user experience, which needs the user to update and restart the app in order to use the app. This approach is best for some situations, where an update is vital for continued use of the app. After a user accepts a prompt update, Google Play manages the future process such as installation and restart the app.

1.立即 :它会立即触发更新,并且需要最小的集成,因为Play会在更新过程中管理用户体验。 换句话说,是全屏用户体验,需要用户更新并重新启动应用程序才能使用该应用程序。 这种方法最适合某些情况,在这种情况下,更新对于继续使用该应用程序至关重要。 用户接受即时更新后,Google Play会管理以后的过程,例如安装和重新启动应用程序。

2. Flexible: it lets you that customize the user experience during the user update. This needs more consideration and design work, but it is eventually much more customizable approach. Once the user has accepted, control is returned immediately back to the app, and the user can continue to use the app while the update is being downloaded. Eventually, when the update is ready, Play will inform the app again, and the app can accomplish a task appropriately. So, the flexible in-app update flow provides the developer the opportunity to customize the experience during the in-app update. Before doing the update operation, you must check if an update is available or not. This is done because if the update is not available, we have to ask the user to update the app. So, it will have a negative impression on the user. For this reason, we should first check, if an update is available or not. To check for an update, you can use the AppUpdateManager. We acquire an instance of an appUpdateManager from Play Core library. This is an object that allows you interact with the in-app update API.

2. 灵活 :它使您可以在用户更新期间自定义用户体验。 这需要更多的考虑和设计工作,但是最终它将是更多可定制的方法。 一旦用户接受,控制权立即返回给应用程序,并且用户可以在下载更新时继续使用该应用程序。 最终,当更新准备就绪时,Play会再次通知应用程序,并且该应用程序可以适当地完成任务。 因此,灵活的应用内更新流程为开发人员提供了在应用内更新期间自定义体验的机会。 在执行更新操作之前,必须检查更新是否可用。 这样做是因为如果没有更新,我们必须要求用户更新应用程序。 因此,它将对用户产生负面印象。 因此,我们应该首先检查是否有可用的更新。 要检查更新,可以使用AppUpdateManager。 我们从Play Core库获取appUpdateManager的实例。 此对象使您可以与应用程序内更新API进行交互。

val appUpdateManager = AppUpdateManagerFactory.create(context)
val appUpdateInfoTask = appUpdateManager.appUpdateInfo
appUpdateInfoTask.addOnSuccessListener { appUpdateInfo ->
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
&& appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.IMMEDIATE)
) {
// Request the update.
}
}

有条件的交付 (Conditional delivery)

Traditionally, all your codes and app contents are always serve to all users. However, you have features that are simply not applicable to some of the users or the some of the devices in some cases. So, Conditional Delivery enables you to control which part of your app would be served to which users. With conditional delivery, you can set a set of conditions under which a feature module would be delivered, and otherwise will be left out. This allows you exclude a certain part of your app from some of the Android devices, and avoid loading your app with irrelevant features to the devices, which it is installed on. This means it optimizes download size and on-device footprint of your app.

传统上,您所有的代码和应用内容始终向所有用户提供。 但是,在某些情况下,您所拥有的功能根本不适用于某些用户或某些设备。 因此, 条件交付使您可以控制将应用程序的哪个部分提供给哪些用户。 使用条件交付,您可以设置一组条件,在该条件下交付功能模块,否则将被排除。 这样一来,您就可以从某些Android设备中排除应用的特定部分,并避免将具有不相关功能的应用加载到安装了该设备的设备上。 这意味着它可以优化应用程序的下载大小和设备占用空间。

Conditional delivery lets you to set certain device configuration requirements for dynamic feature modules to be downloaded automatically during app install. For instance, you can configure a dynamic feature module that includes functionality for augmented reality to be available at app install for just only devices that provide AR.

有条件的交付使您可以为动态功能模块设置某些设备配置要求,以便在应用程序安装期间自动下载这些功能。 例如,您可以配置一个动态功能模块,其中包含用于增强现实的功能,仅在提供AR的设备上才能在应用程序安装时使用。

There are three types of conditions for conditional delivery:

有条件交付的条件分为三种:

  1. Device hardware and software features: You can be able to deliver your module only to devices that support a certain feature like a VR headset.

    设备硬件和软件功能:您只能将模块交付给支持某些功能的设备,例如VR耳机。

2. Specific Country: You can have a module included only for specific countries.

2. 特定国家/地区:您可以包含仅适用于特定国家/地区的模块。

3. SDK version: You can be able to restrict a module by minimum SDK version by targeting only Android devices above a certain version.

3. SDK版本:通过仅针对特定版本以上的Android设备,您可以通过最低SDK版本限制模块。

Configuring conditional delivery is simple. Once you have extracted the feature into the module, the only change needed is adding installation instructions to the android manifest XML. The newly-introduces install time elements let you to specify conditions for delivery. You can mention conditions for device, user country, and min SDK. For instance, delivery is conditioned by device feature and min SDK. Thus, conditions could be combined.

配置条件传递很简单。 将功能提取到模块中后,唯一需要做的更改就是将安装说明添加到android manifest XML。 新引入的安装时间元素使您可以指定交付条件。 您可以提及设备,用户国家/地区和最低SDK的条件。 例如,交付取决于设备功能和最低SDK。 因此,可以组合条件。

<dist:delivery>
<dist:install-time>
<dist:conditions> <dist:device-feature dist:name ="android.hardware.camera.ar"/>
<dist:min-sdk dist:value="24"/> </dist:conditions>
</dist:install-time>
</dist:delivery>

The user country condition lets you exclude or include a module in specific countries, and you can also specify more than one country. In below example, the module will be deployed only to United States and Britain:

用户国家/地区条件使您可以在特定国家/地区排除或包含某个模块,也可以指定多个国家/地区。 在下面的示例中,该模块将仅部署到美国和英国:

<dist:user-countries dist:exclude="false">
<dist:country dist:code="US"/>
<dist:country dist:code="UK"/></dist:user-countries>

按需交付和动态功能 (On-demand delivery and Dynamic feature)

Even if your modules are conditional at install time, but you simply do not know whether a module is relevant for a user or not in some situations. Therefore, on-demand delivery allows you install and remove specific features and modules during the lifetime of an app based on user behavior inside the app. As a matter of fact, Dynamic feature modules let you to separate certain features and resources from the base module of your app, and include them in your app bundle. Through Dynamic Delivery, users can later download, and install those components on demand after they have already installed the base APK of your app. For instance, a feature of an app has been used only by a small numbers of their users, and is rarely used more than once by an individual user. However, it is a relatively large component of this app. As a result, it is a perfect candidate for being a feature module delivered on demand.

即使您的模块在安装时是有条件的,但在某些情况下您也不知道模块是否与用户相关。 因此, 按需交付使您可以根据应用程序内的用户行为在应用程序的生存期内安装和删除特定功能和模块。 实际上,动态功能模块可让您从应用程序的基本模块中分离某些功能和资源,并将其包含在应用程序包中。 通过动态交付,用户可以在以后已经安装了应用程序的基本APK之后按需下载并安装这些组件。 例如,一个应用程序的功能仅由少数用户使用,很少有单个用户使用一次。 但是,它是此应用程序的相对较大的组件。 因此,它是按需交付的功能模块的理想选择。

Image for post
Google Dynamic Delivery Tutorial Google Dynamic Delivery教程中的拆分APK投放的应用的依赖树

The main goals of dynamic delivery are to diminish the amount of time and bandwidth it takes to install an app from the Google Play Store, while also ensuring that only the minimum storage space is used by the app once it is installed. Dynamic feature modules (as on-demand modules) allow the various features, which create an Android app to be packaged into separate modules that are only downloaded and installed onto the device when they are required by the user.

动态交付的主要目标是减少从Google Play商店安装应用程序所花费的时间和带宽,同时还要确保该应用程序安装后仅使用最小的存储空间。 动态功能模块(如按需模块)允许创建Android应用程序的各种功能打包到单独的模块中,这些模块仅在用户需要时才下载并安装到设备上。

游戏资产交付 (Asset delivery for games)

In essence, there are a massive amount of contents for some games that comes from codes and assets in order to start playing. A number of developers are using CDN solutions; however this makes negative effects on User Experience, In addition, the CDN cannot optimize its content and delivery to the requesting clients. So, you have to serve all assets to all users, regardless if they will ever use them. Another main downside of using a CDN is that you cannot rely on auto updates of assets. As a result, this leads to have long waits for updating resources after the game is already installed.

从本质上讲,某些游戏的大量内容来自代码和资产,以便开始玩。 许多开发人员正在使用CDN解决方案。 但是,这会给用户体验带来负面影响。此外,CDN无法优化其内容和向请求客户端的交付。 因此,您必须将所有资产提供给所有用户,无论他们是否会使用它们。 使用CDN的另一个主要缺点是您不能依赖资产的自动更新。 结果,这导致在已经安装了游戏之后要等待很长时间来更新资源。

By extending the App Bundle format to include game assets, asset pack for games is introduced. In contrast to feature modules, asset packs are composed of assets only, with no executable code, and can be extremely large. Asset packs will be packaged in the App Bundle alongside your game binary; therefore, you can be able to publish a single artifact to Play includes everything your game needs. Additionally, you can be rely on Play to keep your assets up-to-date, just like it currently does with your game binary, and similarly to the flexibility you have with feature modules. In short, you will be able to customize asset delivery according to your game needs.

通过扩展App Bundle格式以包括游戏资产,引入了游戏资产包。 与功能模块相比,资产包仅由资产组成,没有可执行代码,并且可能非常大。 资产包将与您的游戏二进制文件一起打包在App Bundle中; 因此,您可以将单个工件发布到Play,其中包括游戏所需的一切。 此外,您可以依靠Play来更新资产,就像当前对游戏二进制文件所做的一样,并且类似于功能模块所具有的灵活性。 简而言之,您将能够根据您的游戏需求自定义资产交付。

Play Asset Delivery is Google Play’s solution for delivering large amounts of game assets by extending the Android App Bundles format. Play Asset Delivery offers developers flexible delivery methods and high performance. It has a small API footprint, and is free to use.

Play Asset Delivery是Google Play的解决方案,可通过扩展Android App Bundles格式来交付大量游戏资产。 Play Asset Delivery为开发人员提供了灵活的交付方式和高性能。 它占用的API很小,可以免费使用。

Play Asset Delivery uses asset packs, which are composed of assets without executable codes. By using Dynamic Delivery, you can customize how and when each asset pack is downloaded onto a device according to three delivery modes: install-time, fast-follow, and on-demand.

Play Asset Delivery使用资产包,资产包由没有可执行代码的资产组成。 通过使用动态交付,您可以根据三种交付方式(安装时间,快速跟进和按需)自定义将每个资产包下载到设备上的方式和时间。

In conclusion, Android App Bundles tackle some previous issues in Android by providing a way for developers to create a single package from within Android Studio, and have custom APK files automatically generated by Google Play for each individual supported configuration. Also, after introducing Android App Bundle, a number of developers have used this approach to optimize delivery in their apps. In this article, some options for customizable delivery in Android development were discussed.

总之, Android App Bundles为开发人员提供了一种在Android Studio中创建单个程序包的方式,并通过Google Play为每个受支持的配置自动生成了自定义APK文件,从而解决了Android中以前存在的一些问题。 同样,在引入Android App Bundle之后,许多开发人员都使用这种方法来优化其应用程序中的交付。 在本文中,讨论了一些Android开发中可自定义交付的选项。

翻译自: https://medium.com/kayvan-kaseb/customizable-delivery-options-in-android-582cc6f3e43a

android中两层选项卡

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值