Android Gradle Plugin 7. Projects that use the Kotlin Multiplatform support need to update to Kotlin 1. As a workaround, you can downgrade the Android Gradle plugin to 4. For more information, see KT There is no lint text output printed to stdout when the lint task is up-to-date issue  For more context, see Behavior changes for lint.
This issue will be fixed in Android Gradle plugin 7. As a workaround, the lint task can be run on those libraries. Starting in version 4. Java 8 provides access to a number of newer language features including lambda expressions, method references, and static interface methods.
For the full list of supported features see the Java 8 documentation. To keep the old behavior, specify Java 7 explicitly in your module-level build. The new JVM resource compiler is enabled by default. Android Gradle Plugin 4. To enable one or both of these formats in your build, add the following properties to your module-level build. This new flag takes care of the APK signing step in the deployment process.
It is now possible to enable or disable app signing in Android Gradle plugin per variant. This example demonstrates how to set app signing per variant using the onVariants method in either Kotlin or Groovy:. To reduce clutter in build output, AGP 4. Previously, a line of output was generated for every file that was built, resulting in a large quantity of informational messages. If you would like to see the entirety of the native output, set the new Gradle property android.
You can set this property in either the gradle. Command line -Pandroid. Starting in AGP 4. In other words, if you declare a property in a gradle. In AGP 4. This change reflects the new Gradle behavior and supports configuration caching. For more information on setting values in gradle. In previous releases, JDK 8 was bundled with Studio. When using the new bundled JDK to run Gradle, this may result in some incompatibility or impact JVM performance due to changes to the garbage collector.
These issues are described below. Android Studio 4. For more information about Gradle compatibility, see Update Gradle. To potentially improve build performance, we recommend testing your Gradle builds with the parallel garbage collector. In gradle. To measure build speed with different configurations, see Profile your build. This causes an increase in APK size, but it results in a smaller installation size on the device, and the download size is roughly the same.
This means that:. This means that it is no longer possible to write the following in Kotlin scripts for some collections that previously supported it:. Android Gradle plugin 4. To export your native libraries, add the following to the android block of your library project's build. In this example, the mylibrary and myotherlibrary libraries from either your ndk-build or CMake external native build will be packaged in the AAR produced by your build, and each will export the headers from the specified directory to their dependents.
Kotlin uses custom metadata in Java class files to identify Kotlin language constructs. R8 now has support for maintaining and rewriting Kotlin metadata to fully support shrinking of Kotlin libraries and applications using kotlin-reflect. For more information, see Shrinking Kotlin libraries and applications using Kotlin reflection with R8 on Medium. When you build the debug version of your app using Android Gradle plugin 4. The cleanBuildCache task and the android.
The android. Starting with this release, fields from R classes are no longer kept by default , which may result in significant APK size savings for apps that enable code shrinking. This should not result in a behavior change unless you are accessing R classes by reflection, in which case it is necessary to add keep rules for those R classes. The experimental flag android. Set in the gradle.
For library projects only, the BuildConfig. Additionally, these values were discarded during manifest merging. In a future version of Android Gradle plugin, the versionName and versionCode properties will also be removed from the DSL for libraries. You can set the path to your local NDK installation using the android.
If you use this property together with the android. We've changed the behavior of how library unit tests are compiled and run. This configuration typically results in better testing. In some cases library unit tests that use data binding may encounter missing DataBindingComponent or BR classes. Those tests need to be ported to an instrumented test in the androidTest project, since compiling and running against those classes in a unit test may produce incorrect output.
The io. Gradle 6. To learn more, read the section about updating Gradle. This minor update supports compatibility with new default settings and features for package visibility in Android  In previous versions of Android, it was possible to view a list of all apps installed on a device.
Starting with Android 11 API level 30 , by default apps have access to only a filtered list of installed packages. For more information on this new feature, see Package visibility in Android  The Build Analyzer window helps you understand and diagnose issues with your build process, such as disabled optimizations and improperly configured tasks.
This feature is available when you use Android Studio 4. You can open the Build Analyzer window from Android Studio as follows:. The Build Analyzer window organizes possible build issues in a tree on the left. You can inspect and click on each issue to investigate its details in the panel on the right.
When Android Studio analyzes your build, it computes the set of tasks that determined the build's duration and provides a visualization to help you understand the impact of each of these tasks.
You can also get details on warnings by expanding the Warnings node. In Android Studio 4. This means that you can now include standard language APIs that were available only in recent Android releases such as java. The desugaring process rewrites your app's code to instead use this library at runtime. To enable support for these language APIs, include the following in your app module 's build. Note that you may also need to include the above code snippet in a library module 's build.
The library module's instrumented tests use these language APIs either directly or through the library module or its dependencies. You want to run lint on the library module in isolation. This is to help lint recognize valid usages of the language APIs and avoid reporting false warnings.
When new features are added, they will be disabled, by default. You can then use the buildFeatures block to enable only the features you want, and it helps you optimize the build performance for your project. You can set the options for each module in the module-level build. Keep in mind, you can still use the buildFeatures block in the module-level build. In previous versions of the Android Gradle plugin, all feature modules could depend only on the app's base module.
When using Android Gradle plugin 4. That is, a :video feature can depend on the :camera feature, which depends on the base module, as shown in the figure below. Feature module :video depends on feature :camera , which depends on the base :app module. This means that when your app requests to download a feature module, the app also downloads other feature modules it depends on.
For example, the :video module declares a dependency on :camera as follows:. When building your app using Android Gradle plugin 4. When uploading your app, the Play Console inspects this metadata to provide you with the following benefits:.
The data is compressed, encrypted by a Google Play signing key, and stored in the signing block of your release app. When you follow the configuration steps described below, Gradle automatically makes these native libraries available to use with your external native build system, such as CMake. Note that Gradle only makes these libraries available to your build; you must still configure your build scripts to use them.
Libraries are exported using the Prefab package format. Each dependency can expose at most one Prefab package, which comprises one or more modules.
A Prefab module is a single library, which could be either a shared, static, or header-only library. Typically, the package name matches the Maven artifact name and the module name matches the library name, but this is not always true. Because you need to know the package and module name of the libraries, you might need to consult the dependency's documentation to determine what those names are. CMake ndk-build. This value will be set automatically by Gradle when CMake is invoked, so if your build system modifies this variable, be sure to append rather than assign to it.
This command searches for config-file packages that match the given package name and version and exposes the targets it defines to be used in your build. For example, if your application defines libapp. When you build your project, your external native build system automatically links libapp. For additional information, refer to the curl prefab sample. The behavior for app signing configurations in the signingConfig block has changed to the following:.
These changes allow AGP to optimize builds by disabling the signing mechanism based on whether the user has explicitly enabled these flags. Prior to this release, it was possible for v1Signing to be disabled even when explicitly enabled, which could be confusing. Android Gradle plugin 3. In Android Gradle plugin 4.
So, to use the latest Android Gradle plugin, you need to migrate your instant app to support Android App Bundles. By migrating your instant apps, you can leverage the benefits of app bundles and simplify your app's modular design. The ability to separate annotation processing into a dedicated task has been removed. This option was used to maintain incremental Java compilation when non-incremental annotation processors are used in Java-only projects; it was enabled by setting android.
Instead, you should migrate to using incremental annotation processors to improve build performance. The Android Gradle plugin no longer checks for or includes annotation processors you declare on the compile classpath, and the annotationProcessorOptions.
If you include annotation processors on the compile classpath, you might get the following error:. To resolve this issue, you must include annotation processors in your build. To learn more, read Add annotation processors. Prior versions of the Android Gradle Plugin required that you explicitly package any prebuilt libraries used by your CMake external native build by using jniLibs.
With Android Gradle Plugin 4. External native build now automatically packages those libraries, so explicitly packaging the library with jniLibs results in a duplicate. To avoid the build error, move the prebuilt library to a location outside jniLibs or remove the jniLibs configuration from your build. Changes in Android Gradle plugin 4. Gradle 5. View binding provides compile-time safety when referencing views in your code. You can now replace findViewById with the auto-generated binding class reference.
To start using View binding, include the following in each module's build. The Android Gradle plugin includes support for the Maven Publish Gradle plugin , which allows you to publish build artifacts to an Apache Maven repository. The Android Gradle plugin creates a component for each build variant artifact in your app or library module that you can use to customize a publication to a Maven repository.
To learn more, go to the page about how to use the Maven Publish plugin. When building the debug version of your app, the plugin uses a new packaging tool, called zipflinger , to build your APK. This new tool should provide build speed improvements. If the new packaging tool doesn't work as you expect, please report a bug. You can revert to using the old packaging tool by including the following in your gradle. Gradle can output a Chrome trace that contains timestamps for these compiler events so you can better understand the time required to build your project.
To output this build attribution file, do the following:. Add the flag -Pandroid. The file is named profile- timestamp. When you build your app, the plugin now sets extractNativeLibs to "false" by default. That is, your native libraries are page aligned and packaged uncompressed. While this results in a larger upload size, your users benefit from the following:. If you want the Android Gradle plugin to instead package compressed native libraries, include the following in your app's manifest:.
If you download multiple versions of the NDK, the Android Gradle plugin now selects a default version to use in compiling your source code files. Previously, the plugin selected the latest downloaded version of the NDK. Use the android. The Android Gradle plugin simplifies the compile classpath by generating only one R class for each library module in your project and sharing those R classes with other module dependencies.
This optimization should result in faster builds, but it requires that you keep the following in mind:. This behavior change should result in fewer Resource Not Found runtime exceptions and improved build speed.
When compiling your app, D8 now respects when annotations apply a CLASS retention policy, and those annotations are no longer available at runtime.
Android Lint can take much longer to complete on some projects due to a regression in its parsing infrastructure, resulting in slower computation of inferred types for lambdas in certain code constructs. If your app defines custom permissions in its manifest, the Android Gradle plugin typically generates a Manifest. The plugin packages this class with your app, so you can more easily reference those permissions at runtime.
Generating the manifest class is broken in Android Gradle plugin 3. If you build your app with this version of the plugin, and it references the manifest class, you might see a ClassNotFoundException exception. To resolve this issue, do one of the following:.
Notably, improving project build speed was a main focus for this update. For information about these and other Project Marble updates, read the Android Developers blog post or the sections below. This minor update supports Android Studio 3.
To see a list of noteable bug fixes, read the related post on the Release Updates blog. The Data Binding annotation processor supports incremental annotation processing if you set android. This optimization results in improved incremental build performance. For a full list of optimized annotation processors, refer to the table of incremental annotation processors.
Additionally, KAPT 1. When you enable unit tests to use Android resources, assets, and manifests by setting includeAndroidResources to true , the Android Gradle plugin generates a test config file containing absolute paths, which breaks cache relocatability.
You can instruct the plugin to instead generate the test config using relative paths, which allows the AndroidUnitTest task to be fully cacheable, by including the following in your gradle. When using Kotlin Gradle plugin 1. To resolve this issue , upgrade the plugin to version 1.
New lint check dependency configurations: The behavior of lintChecks has changed and a new dependency configuration, lintPublish , has been introduced to give you more control over which lint checks are packaged in your Android libraries.
The following code sample uses both dependency configurations in a local Android library project. In general, packaging and signing tasks should see an overall build speed improvement. If you notice a performance regression related to these tasks, please report a bug. Slices bring relevant parts of your favorite apps to the surface. Next time you search for Lyft, you can see prices and driver ETAs right within your results.
Switch between apps and get to what you need more naturally by using gestures instead of buttons. Get a better idea of how often you use your phone. You can see how many notifications you get, plus how much time you spend in apps and how often you check your phone.
Set a daily schedule to get your phone ready for bed. Your screen fades to Grayscale, while Do Not Disturb silences notifications for a restful sleep. You can activate Do Not Disturb anytime you want to disconnect. Accessibility Menu: With Android 9's new accessibility menu, common actions like taking screenshots and navigating with one hand are now easier for motor impaired users.
Simply select text when using the camera or in picture, and the text will be highlighted and read aloud. Sound amplifier: This new Accessibility Service makes it easier to understand conversations by dynamically adjusting over settings to boost the audio in scenarios such as a loud restaurant, bar, or concert.
Battery Saver: Battery Saver keeps your charge going longer than ever by turning off features like the Always-On display. Plus, you have more control over when it comes on - so you can go further on one charge. Adaptive Battery: This feature uses machine learning to predict which apps you'll use in the next few hours and which you likely won't, so your phone only spends battery power on the apps you care about.
Adaptive Brightness: With Adaptive Brightness, your phone learns how you set your screen's brightness in different lighting environments and automatically does it for you over time.
Background restrictions: Now, you'll see recommendations in Settings to restrict certain apps that use too much battery, so you can have more control over your battery. Multi-camera support: With Android 9, developers can now create immersive experiences using streams from two or more physical cameras, such as on devices with either dual-front or dual-back cameras.
Examples include depth, bokeh, stereo vision, and more. Do Not Disturb: Improvements to Do Not Disturb to silence not just notification sounds, but also all the visual interruptions. Calls from starred contacts will still come through, so you don't have to worry about missing something urgent. App dashboard: Get a daily view of the time spent on your phone, how frequently you use different apps, and how many notifications you get.
Wind Down: Set a daily schedule to get your phone ready for bed. Grayscale fades your screen to gray while Do Not Disturb silences notifications for a restful sleep. App timers: App timers let you set daily time limits for your apps.
When you reach the limit, the app is paused for the rest of the day. Display cutout: Support for devices with cutouts to make use of available screen space. Edge-to-edge screens: Support for devices with and taller aspect ratios, and devices with display cutouts. Multiple users on dedicated devices: Android 9 makes it easy for users to share a single device, good for shift workers or public kiosks. Work tab in launcher: Now, you can visually separate your work apps. Tap on the work tab to see work apps all in one place, and turn them off with a simple toggle when you get off work.
Postpone Over-the-air OTA updates: Android 9 now provides the ability for Enterprise IT admins to define freeze periods up to 90 days during which time devices in their fleet will not update the Android OS. This ensures their devices states remain unchanged during critical time like holidays.
Multiple Bluetooth connections: With Android 9, you can connect up to five Bluetooth devices and switch between these devices seamlessly. Incoming phone calls will be sent to all connected Bluetooth devices that can accept, so you'll never miss a call. Sound delay reporting: Android 9 offers support for headsets with sound delay reporting, so video on your device and audio on your headphones can always stay in sync.
Volume memory per Bluetooth device: Android 9 will now remember the last volume you set for each of your Bluetooth devices. No more blasting music too loudly when you reconnect to your car or headphones. HDR improves the brightness and color range of video to improve the picture quality and experience. HD Audio: Improved performance and support for HD audio delivering clearer, sharper, and richer quality sound.
Notification enhancements for messaging: Now, messaging apps can provide suggested 'smart replies' in the notification, so you can respond in a tap. Plus, any inline reply drafts won't disappear if you navigate away, and you'll be able to see images sent from your friends right in the notification.
Manage Notifications: You now have a quick way to turn off notifications from a range of apps, so you only receive those that are helpful to you.
0コメント