关注你的成果

Lin Wang | Android Performance Engineer

王琳 | 安卓性能工程师

Black magnifying glass with “</” inside of the glass portion and “manifest >” to the right of the magnifying glass

Designed by AJ Oxendine | Software Engineer

设计者:AJ Oxendine | 软件工程师

It’s a well-known fact for Android developers that an app’s manifest (AndroidManifest.xml) holds crucial application declarations. It is rarely monitored after being set up because we assume it hardly ever changes. At Pinterest, however, we have been actively monitoring the manifest after realizing it does change every so often.

对于安卓开发者来说,一个众所周知的事实是,应用程序的清单(AndroidManifest.xml)拥有关键的应用程序声明。它在被设置后很少被监控,因为我们认为它几乎不会改变。然而,在Pinterest,我们在意识到清单确实经常变化之后,一直在积极监测清单。

While building an app, Gradle downloads all the dependent libraries to compile and link them with the app. These dependent libraries each have their own mini manifest. During the build process, Android Gradle Plugin (AGP) merges them with the app’s main manifest to form the final manifest. Because of this merging process, the final manifest often looks quite different from the original one and contains additional declarations. In most cases, these extra declarations are necessary for dependent libraries to function. However, sometimes they can have unintended behaviors.

在构建一个应用程序时,Gradle会下载所有的依赖库,以便将它们与应用程序编译和链接。这些依赖库都有自己的小清单。在构建过程中,Android Gradle插件(AGP)将它们与应用程序的主清单合并,形成最终清单。由于这个合并过程,最终清单看起来往往与原来的清单大不相同,并包含额外的声明。在大多数情况下,这些额外的声明对于依赖库的运作是必要的。然而,有时它们会产生意想不到的行为。

It first caught our attention during a cold start regression investigation. We found a 3rd party Software Development Kit (SDK) declaring a special ContentProvider in its manifest to warm up itself as early as possible. This is because content providers get initialized very early during the application startup, even before the Application’s onCreate() method is invoked. However, we want to control every 3rd party libraries’ initialization and only initialize them when it is necessary. Therefore, we added the following declaration:

它首先在一次冷启动回归调查中引起了我们的注意。我们发现一个第三方软件开发工具包(SDK)在其清单中声明了一个特殊的ContentProvider,以尽可能早地预热自己。这是因为内容提供商在应用程序启动期间很早就被初始化了,甚至在应用程序的onCreate()方法被调用之前。然而,我们想控制每一个第三方库的初始化,只在必要时...

开通本站会员,查看完整译文。

首页 - Wiki
Copyright © 2011-2024 iteam. Current version is 2.125.0. UTC+08:00, 2024-05-05 13:10
浙ICP备14020137号-1 $访客地图$