The new Android Studio 4.0 comes with a new startup interface. Today, Google I/O officially announced the beta version of Android Studio 3.5, one month after the release of Android Studio 3.6 beta, The recent Android Dev Summit brought us a preview of Android Studio 4.0, and today we’ll take a look at what the new Android Studio 4.0 will bring to developers.

Next, I will update you on the latest development of Android Studio 4.0 based on the content shared in the Android Dev Summit and my own understanding. If you haven’t been following me, please follow me and my official account. If you find any of these articles interesting, be sure to share, retweet, comment and like them!

Compile build aspect

New Build window. After each Build, a new Build Speed window will appear. In this window, we can check the time consuming of different plug-ins and tasks during the whole Build and make targeted repairs. It will also remind us which plug-ins are always executed during each Build, helping us find problems, reduce unnecessary plug-in execution, and shorten Build times. There are a lot of categories, and you can go through them one by one if you’re interested.

In previous articles, I shared some good Kotlin projects with you, including an official Open source Gradle koltin-Dsl-sample. The post is here: Kotlin Open Source Project of the Week

Now Android Studio 4.0 has perfected the Kotlin Gradle DSL code prompt, and you can view the DSL documentation directly in the IDE. As we all know from the default Groovy writing, Android Studio automatically checks for updates to existing dependency libraries, but now the Kotlin Gradle DSL still supports this feature as well.

In compiling, added new coreLibraryDesugaringEnabled true instructions, open this instruction, we can use some advanced API in Java 8.

Such as shown in the chart above, the list. The stream () method, by default, it can only be used in API over 24, through open coreLibraryDesugaringEnabled can eliminate the version of the restrictions, in 24 devices below API can also use this method. Stream, java.util. Time, java.util. Function, ConcurrentHashMap, etc. This feature is intended to address persistent bugs on older versions that cannot be fixed due to the inability to use Java’s advanced apis.

The new Android Studio 4.0 provides syntax highlighting, code prompts, and error checking when editing ProGuard files, as well as updating the corresponding fields in ProGuard files with Refactor names.

The viewBinding directive has been added. When true is enabled, the compiler generates a viewBinding class for us, the ActivityMainBinding shown in the image below.

The purpose of a viewBinding is to ensure that the View we use in our code actually exists in the attempt. Prevents crashes with findViewById null. (but I did not open 4.0 Canary 1 successfully, there should be a bug 😂)

In the view

There are currently three ways to write your UI: XML, code your custom View, and Jetpack Compose. All three are currently previewed on Android Studio 4.0.

The preview interface for all three is the same, with three modes: Edit, preview and Edit + Preview. Among other things, custom View supports preview, which is really very convenient and can greatly improve development efficiency.

Furthermore, the VIEW preview of XML supports simultaneous preview of multiple devices with different resolutions, preview of typesetting in different languages during internationalization, and support for color blindness mode. (Of course, the latter two are not in 4.0 Canary 1 yet, but are explained in the official demo video)

Another cool thing about Android Studio 4.0 is that it supports embedded emulators. Note that the graphics interface in the image above is not our first preview interface. It is a real emulator, developing on the left and debugging on the right.

The Layout Inspector has also been updated. The previous Layout Inspector is similar to a Layout snapshot, and you need to restart the Layout Inspector after switching screens. The Layout Inspector in Android Studio 4.0 supports automatic updates in real time. When our device switches pages, the Layout analyzer also updates the page, and the display of resource files is more complete, adding information about the full call chain. There’s also a really cool feature (highlighted!) The Layout Inspector supports 3D model inspection, as shown below:

Although the official video says that this will be in Android Studio 4.0, in the version of Canary 1 that I was able to download, the custom View preview, the embedded emulator, and the new Layout Inspector were not found. Subsequent Canary should be supported gradually.

animation

In one post, I introduced to you: How many of the 8 Android animations have you used? The last one is MotionLayout, but I also said:

With MotionLayout we need to customize the MotionScene in the XML, specifying the changes between different layouts in the MotionScene.

Android Studio 4.0 now supports a new animation editor that allows you to visually create MotionLayout animations.

You can specify the start and end state of the Layout, set the duration of the animation, and click on the Transition line to preview the animation. Moreover, we can arbitrarily add key frames in the duration, set the state of each frame, control the animation effect of finer granularity, and set the properties and relative positions of key frames. With MotionLayout and the new animation editor, animating on Android is no longer limited by your API but by your imagination.

other

These are some of the most recent developments in Android Studio that we’ve seen in this Android Dev Summit. Behind these features, of course, are improvements in memory usage, compilation speed, and the IDE itself. Otherwise, the version number would not have jumped to 4.0. Next door, Xcode is 11 years old and Android Studio is 4.0 years old.

Tomorrow, I will bring you the latest progress on Android 10 Scoped Storage. If you haven’t followed me, please follow me and my wechat account. If you find any of these articles interesting, be sure to share, retweet, comment and like them!

I’m Wanbo, come on!