Apps get bit animated: Android Studio 4.0 released with new Motion Editor

Google's free IDE is high quality but doesn't remove all the annoyances of Android development

Google has released Android Studio 4.0, a massive update to its IDE for mobile app development, with features like an upgraded Layout Inspector, and the brand new Build Analyzer and motion editor.

Android Studio is based on JetBrains IntelliJ IDEA, a popular Java IDE, and version 4.0 uses IDEA 2019.3.3, according to the release notes, which came out in February 2020. The Android Studio incarnation is a little behind IDEA, for which version 2020 is out.

JetBrains has said the main focus of 2019.3 is performance, claiming faster IDE startup, better UI responsiveness and reduced memory consumption. Startup time is still not great though, particularly for the first run after switch-on, taking over a minute on a well specified PC (Core i7-7700 with 16GB RAM). Microsoft's Visual Studio 2019 takes under 15 seconds on the same machine.

Google has released Android Studio 4.0

Google has released Android Studio 4.0

The main supported languages in Android Studio are Java and Kotlin. Kotlin was developed by JetBrains and made open source under the Apache licence. The language targets the JVM (Java Virtual Machine) and was launched in 2011.

In 2017 it gained the ability to compile to JavaScript, and in 2019 became the Google-recommended language for Android development. It has been a remarkable success, "the second fastest growing language we've seen outside of Swift," Redmonk analyst Stephen O’Grady commented. The reason is that Kotlin added a bunch of nice features that Java lacks, or lacked at the time, including a type system that eliminates most null reference errors.

Language support in Android Studio does not stop at Java and Kotlin. Devs can include C and C++ code in order to use the Android NDK (Native Development Kit). Devs can also install plugins for other languages including Dart (used by the cross-platform Flutter framework).

The Motion Editor in Android Studio 4.0

The Motion Editor in Android Studio 4.0

New features

A big new feature in Android Studio 4.0 is the motion editor. We gave it a try: nothing too ambitious, just moved a piece of text around the screen. It is based on a ConstraintLayout, which lets you position elements relative to other elements or layouts. The starting point then is to add a ConstraintLayout to a project, which requires declaring the repository in the gradle file, and then adding a dependency on the ConstraintLayout library like this:

dependencies { 
implementation "androidx.constraintlayout:constraintlayout:2.0.0-beta6" 

To use the Motion Editor then, oen has to specify the exact version of a dependency library. How does one even know if beta6 is the latest version? The answer is to go to the repository index and do a search; then one can see all the versions of the library listed. At the time of writing beta6 was indeed the latest. Now developers can add a ConstraintLayout to a project, and then right-click the layout and choose Convert to MotionLayout. Next, put a view in it (in our case a TextView), select it, and the Motion Editor appears. One can set different constraints for Start and End, and add further keyframes as needed. One can also add ConstraintSet elements for some special effects, including alpha, visibility, rotation, translation and scale; and CustomAttributes for other effects such as changing the colour. It all worked for us and animation in Android is easier than before.

A new Layout Validation tool previews a layout on multiple devices. Google's Pixel range is included by default, otherwise it is a matter of adding one's own previews specifying display size, Android API, orientation and theme. It is a handy feature but does take up a lot of screen space. It is possible to float windows in Android Studio which is helpful for this kind of tool.

Android Studio 4.0 has an upgraded Layout Inspector which connects to a oen's app while it is running on a device or emulator, to show the user interface elements. This now includes a 3D view, and the ability to drill down the hierarchy of layouts and views. It has a similar purpose to element and CSS inspectors in web browsers, to troubleshoot why one's display does not look as hoped or expected.

C++ developers benefit from a switch to clangd to drive smart editor features like code completion and error detection. A utility called clang-tidy is also bundled, for automatic formatting of C or C++ code.

Another new feature is the Build Analyzer, which is a profiler for the build process, showing the time taken for each step. The tool can detect steps that take the most time, or which do not support incremental builds and therefore always run, perhaps unnecessarily. The full list of what is new is here.

Android Studio is free and of high quality, but developing for Android still has annoyances. Some of these are inherent to the problem of mobile development, targeting thousands of different devices running various versions of Android. Start a new project and one has that difficult choice: which minimum API to support, trading features for compatibility? The IDE gives an estimate of what percentage of devices will be able to run oen's app, with version 8.1 Oreo the newest that can be usd if a developer want to target over 50 per cent of devices.

Update hell: a familiar sight for Android developers

Update hell: a familiar sight for Android developers

Update hell is another feature of Android development, particularly if you come back to it after a break of a few weeks. Not all updates are quick, so prepare to go for a coffee break. On Windows if developer use Hyper-V (as many do) they will have to put up with errors as Intel HAXM tries and fails to install.

Flutter development in Android Studio

Flutter development in Android Studio

There are many pieces to Android Studio including the IDE itself, the Gradle build system, Maven repositories, and a blend of XML, visual designers and Java or Kotlin code for the actual project. It is a complex system and can be hard to troubleshoot. Google's Flutter project has a cross-platform aspect, but is perhaps easier to work with than a native Android application, if one can live with Dart rather than Java or Kotlin. The complexity is still there, but better hidden. Part of the thinking behind Flutter may be to lower the barriers to entry for Android development, as well as increasing productivity for professionals. ®

Similar topics

Other stories you might like

Biting the hand that feeds IT © 1998–2022