Check out the on-demand sessions from the Low-Code/No-Code Summit to learn how to successfully innovate and achieve efficiency by upskilling and scaling citizen developers. Watch now.
Google today launched Android Studio 4.0, the latest version of its integrated development environment (IDE). Android Studio 4.0 is supposed to help developers “code smarter, build faster, and design apps.” The new release comes right before Google’s Android 11 Beta 1 launch next week. Google delayed its Android 11 beta schedule due to the coronavirus.
Android is a massive platform with over 2.5 billion monthly active devices. While developers can use other IDEs to build on Android, the latest features arrive first in Android Studio. Version 4.0 includes a new Motion Editor, a Build Analyzer, and Java 8 language APIs. Google also overhauled the CPU Profiler user interface and improved the Layout Inspector.
You can now download Android Studio 4.0 for Windows, Mac, and Linux directly from developer.android.com/studio. If you are already using Android Studio, you can get the latest version in the navigation menu (Help => Check for Update on Windows/Linux and Android Studio => Check for Updates on OS X).
Google released Android Studio 3.6 in February. The version number 4.0 suggests this is a major release for anyone who builds apps and games for Android.
Below you’ll find Android Studio 4.0 features broken down by category: design, develop, and build. The new version also includes the usual performance improvements and bug fixes on top of the new features (full release notes). Google didn’t share its plans for the next version. Normally we’d get hints at the company’s I/O developer conference, but 2020 is a weird year.
Android Studio 4.0 design features
- Motion Editor: The MotionLayout API extends the rich capabilities of
ConstraintLayoutto help Android developers manage complex motion and widget animation in their apps. It’s now easier to use this API with the new Motion Editor — an interface for creating, editing, and previewing
MotionLayoutanimations. You no longer have to create and modify complex XML files; the Motion Editor generates them for you, with support for editing constraint sets, transitions, keyframes, and view attributes. If you do want to see the code the editor creates, it is one click away. For developers already using
ConstraintLayout, the IDE can easily convert those to
- Upgraded Layout Inspector: Investigate where a value for a particular attribute came from or see a live 3D representation of nested views to inspect your view hierarchy. The Layout Inspector gives you access to data that stays updated with your running app and providing insights on how resources are being resolved. Use the live Layout Inspector by selecting View > Tool Windows > Layout Inspector from the main menu. If you are deploying to a device running API 29 level or higher, you have access to additional features, such as a dynamic layout hierarchy that updates as views change, detailed view attributes that also help you determine how resource values are resolved, and a live 3D model of your running app’s UI. Navigate, animate, and transition between views on your running app while being able to debug your UI.
- Layout Validation: When you’re developing for multiple form-factors, screen sizes, and resolutions, you need to verify that changes you make to your UI look great on every screen you support. With the Layout Validation window, you can preview layouts on different screens and configurations simultaneously. To get started, click on the Layout Validation tab in the top-right corner of the IDE.
Android Studio 4.0 develop features
- CPU Profiler UI upgrades: The CPU profiler is designed to provide a rich amount of information about your app’s thread activity and trace recordings. CPU recordings are now separated from the main profiler timeline and organized in groups. You can move groups up and down, or drag-and-drop individual items within a group for additional customization. You can now view all thread activity in the Thread Activity timeline (including methods, functions, and events) and try new navigation shortcuts to easily move around the data — such as using W, A, S, and D keys for fine-grained zooming and panning. Google also redesigned the System Trace UI so Events are uniquely colored for better visual distinction, threads are sorted to surface the busier ones first, and you can now focus on seeing data for only the threads you select. The quality of the CPU profiler should also be better — Google has seen a significant decrease in the user-reported error rates of recordings since Android Studio 3.6.
- Smart editor features when writing rules for code shrinking: R8 was introduced in Android Gradle plugin 3.4.0 to combine desugaring, shrinking, obfuscating, optimizing, and dexing — resulting in noticeable build performance improvements. When creating rules files for R8, Android Studio now provides smart editor features, such as syntax highlighting, completion, and error checking. The editor also integrates with your Android project to provide full symbol completion for all classes, methods, and fields, and includes quick navigation and refactoring.
- IntelliJ IDEA 2019.3 platform update: The core Android Studio IDE has been updated with improvements from IntelliJ IDEA 2019.3 and 2019.3.3 releases. These improvements largely focus on quality and performance improvements across the IDE.
- Kotlin Android live templates: An IntelliJ feature that allows you to insert common constructs into your code by typing simple keywords. Android Studio now includes Android-specific live templates for your Kotlin code. For example, simply type
toastand press the Tab key to quickly insert boilerplate code for a Toast. For a full list of available live templates, navigate to Editor > Live Templates in the Settings (or Preferences) dialog.
- Clangd support for C++: For developers writing C++, clangd is now the primary language analysis engine for code navigation, completion, inspection, and showing code errors and warnings. Google also now bundles clang-tidy with Android Studio. To configure Clangd or Clang-Tidy behavior, go to the IDE Settings (or Preferences) dialog, navigate to Languages & Frameworks > C/C++ > Clangd or Clang-Tidy, and configure the options.
Android Studio 4.0 build features
- Build Analyzer: Outdated or misconfigured tasks can cause longer build times that lead to frustration and lost productivity. The Build Analyzer helps developers understand and address bottlenecks in your build by highlighting the plugins and tasks that are most responsible for your overall build time and by suggesting steps to mitigate regressions.
- Java 8 Language library desugaring in D8 and R8: Previous versions of the Android Gradle plugin supported a variety of Java 8 language features for all API levels, such as lambda expressions and method references, through a process called desugaring. Now, the desugaring engine has been extended to support Java language APIs, regardless of your app’s minSdkVersion. This means that you can now use standard language APIs, which were previously available in only recent Android releases (such as java.util.stream, java.util.function and java.time).
- Feature-on-feature dependencies: You can now specify that a Dynamic Feature module depends on another feature module. Being able to define this relationship ensures that your app has the required modules to unlock additional functionality, resulting in fewer requests and easier modularization of your app. For example, a
:videofeature can depend on the
:camerafeature. If a user wants to unlock the ability to record videos, your app automatically downloads the required
:cameramodule when it requests
- New options to enable or disable build features: The Android Gradle plugin has built-in support for modern libraries, such as data binding and view binding, and build features, such as auto-generated BuildConfig classes. However, you might not need these libraries and features for every project. You can now disable discrete build features, which can help optimize build performance for larger projects.
- Essential support for Kotlin DSL script files: Built-in support for Kotlin DSL build script files (*.kts) means that Kotlin build scripts offer a full suite of quick fixes and are supported by the Project Structure dialog. Google will continue to refine the Android Gradle Plugin’s DSL API throughout the next year, which may result in breaking API changes for Kotlin script users. Long term, these fixes will make for a more idiomatic, easy-to-use DSL for Kotlin script users.
- Dependencies metadata: When building your app using Android Gradle plugin 4.0.0 and higher, the plugin includes metadata that describes the library dependencies that are compiled into your app. When uploading your app, the Play Console inspects this metadata to provide alerts for known issues with SDKs and dependencies your app uses, and, in some cases, provide actionable feedback to resolve those issues. The data is compressed, encrypted by a Google Play signing key, and stored in the signing block of your release app.
Lastly, Android Gradle plugin 4.0.0 includes support for Android Studio’s Build Analyzer by using Java 8 language APIs (regardless of your app’s minimum API level), and creating feature-on-feature dependencies between Dynamic Feature modules.
VentureBeat's mission is to be a digital town square for technical decision-makers to gain knowledge about transformative enterprise technology and transact. Discover our Briefings.