Android Gradle 8.0 plugin improves build times, requires updating third-party plugins and libraries

Android Gradle 8.0 plugin improves build times, requires updating third-party plugins and libraries

Google has announce The upcoming Android Gradle (AGP) plugin, version 8.0, reduces build times by removing a file Transform APIs and replace it through Artifacts API And the Hardware API. All third-party plug-ins and applications that depend on it are required to migrate to the new APIs.

The Transform API is removed to improve build performance. Projects using the Transform API AGP are forced to use a less optimized build flow which can lead to significant regression in build times.

Transform APIs are a set of APIs provided by the Android Gradle plug-in to handle intermediate artifacts of the build process, enabling bytecode transformation, compiling new classes, or parsing the entire program.

Typical use of this feature is to use compiled tools to add effects, custom logging, performance analysis, etc. For example, Android Helper Hilt Transform APIs are used to include Dagger dependency injection in an Android application and Firebase uses it to monitor performance. While Transform APIs are typically used in Gradle plugins, there are also a number of libraries that use them, such as mobile database world. In addition, the conversion features may be useful in creating test classes.

For developers, this change means that they may need to migrate their code, as well as update any dependencies using Transforms APIs to newer versions using alternate APIs. While a number of plugins and libraries, including the mentioned Hilt, Firebase, and Realm, are working to adopt the new APIs, the migration is not likely to cause some trouble for developers. In particular, upgrading to the latest version of a plugin/library may not be as simple as changing its version number in the config file, but it may also require modifications to the codebase you are using.

to make immigration As easy as it can be, Google is making new alternate APIs available in AGP 7.2 so that developers can modify their code in preparation for version 8. AGP 7.2 will issue a prominent warning for every use of Transformational APIs, which will cause AGP 8 to fail. To make an AGP warning provide more details about the component that is causing it, you can set it android.debug.obsoleteApi=true in gradle.properties.

As mentioned, there are two distinct APIs that replace Transform: the hardware API, which can be used to transform bytecode, and the Artifacts API, which allows new classes to be added to the application. Google has not provided specific information regarding the reduced build time that the new plugin has brought. Anyway, some details on how to achieve this can be inferred from the Google docs.

Specifically, to make the hardware API fast, AGP restricts hardware code to run independently in each class without seeing the other classes. The first benefit this provides is that the libraries can be used in parallel rather than at the end of compilation. It also speeds up additional builds, since a change in a class will only require that that class and those that depend on it be processed again.

With regards to the Artifacts API, it seems that the main factor in achieving the performance benefit is isolating the transformation of the entire program’s analysis into a specific API, called handmade products. This API should be used with caution, Google says, since it has a high build performance cost, and making it a separate part means you can handle cases where this kind of analysis isn’t used as a whole program more efficiently.


#Android #Gradle #plugin #improves #build #times #requires #updating #thirdparty #plugins #libraries

Leave a Comment

Your email address will not be published. Required fields are marked *