Monday, September 24, 2018

Android Studio 3.2 hits Stable, brings Emulator Snapshots, Energy Profiler, and more

It’s been quite a while since Google first launched their first-party integrated development environment, Android Studio, to give developers the tools to help them build all kinds of apps for Android. Before the initial launch, developers had to use third-party IDEs and all kinds of unsupported plugins and software. That time has long since passed as Android Studio keeps getting better and better, adding a stable emulator, reliable logging tools, and so much more. Just today, Google released the stable version of Android Studio 3.2. We’ve talked about it previously while it was still undergoing some beta testing. But now, with everything more polished, stable version 3.2 has been released. Let’s break down all the new major features.

Updated “What’s new” Assistant

Upon downloading or updating to Android Studio 3.2, you’ll now see an updated “What’s New” assistant, AKA the changelog. You can also open it manually by going to Help > What’s new in Android Studio. Here’s how it looks:

Android Jetpack

We’ve previously talked about Android Jetpack, which is a set of tools that helps developers to simplify application code. Its components are mainly categorized into four sections: Architecture, UI, Foundation, and Behavior. It was first introduced at Google I/O 2018 just 4 months ago. What’s important is that Android Jetpack is built with Kotlin in mind, which is now a coding solution fully supported by Google. That’s why it also comes with Android KTX, which is a set of extensions to help developers write cleaner code in Kotlin.

Android Jetpack Components

Navigation Editor

Most applications are made of tens of activities nowadays and developers also need to share the information between the activities. Different choices, categories, tabs, or other kinds of segments lead to the different activities. This makes it difficult to control all of them and share data between them. That’s why Google decided to come up Navigation Editor—a graphical interface for viewing the structure of the application and the activities.

Android Jetpack Android Studio Kotlin

Navigation Editor has been available since the Canary builds under the Preferences > Experimental category. I’m sure you’ll agree that Navigation Editor will definitely make some developers’ lives easier as the graphical interface is much cleaner and simpler.

AndroidX Migration

AndroidX is a reimagined Android Support Library, which gives developers the ability to write applications for different versions of Android. AndroidX just recently went open-source, which means that everyone can take part in contributing to the project. In Android Studio 3.2, you’ll see an option to convert your application to an AndroidX supported one, under Refactor > Migrate to AndroidX.

This sets the flags android.useAndroidX and android.enableJetifier to true. This orders the application to run with AndroidX support and to convert all the existing tools as if they were written for Android X. These flags are set to false by default.

Android App Bundle support

I’m sure many developers are irritated by supporting a whole bunch of different devices. Devices can come with different SoC architecture, different screen sizes and resolutions, different languages, different software, and so on. As you can imagine, supporting all of them might mean cramming everything into a single APK file. Well, at least, it used to mean that.

The problem was that this method was not efficient as installing these kinds of applications could take a lot of space on the user’s device. Google came up with a few solutions over the years, and their most recent one is the Android App Bundle. From now on, you build an App Bundle and then upload the bundle to the Play console. Then, Google Play Dynamic Delivery will ensure that only the required part of the code gets delivered to the user. So, if someone installs your application on the Nexus 6P, they’ll get an APK that supports 5.7-inch screen at 1440p resolution, and so on. Building these Bundles is possible by going to Build > Build Bunde(s) / APK(s) > Build Bundle(s).

Sample data in Layout Editor

Previously, if you wanted to see the look and feel of the layout, you had to test the application on either an emulator or an actual Android device, per runtime data requirements. From now on, you’ll have an ability to fill in the sample data you and see how the application looks right in the Android Studio IDE. You just have to click on the layout editor wrench icon in the Design window. There are multiple sample data templates available.

Slices

Another feature that was announced with Android Pie is Slices. Basically, it gives developers the ability to put the slice of an application’s specific activity/interface inside Google search. Android Studio 3.2 has Slices API support, so now any developer can use it.

Android Slices Android Jetpack

Slices in the Google App. Source: Google

Android Profiler

Android Profiler is, in my humble opinion, the most important feature of Android Studio 3.2. The Profiler measures your application’s performance and how much impact it has on the device. You can also save the Profiler data to examine or compare later. It has a couple of features. System Trace lets you see the CPU activity, Memory Profiler measures the memory allocation on the device, and so on. You can also export, import, and inspect the memory heap dump files and CPU traces created by Memory Profiler and CPU Profiler respectively. Recording the CPU activity during app startup is also possible.

Lint checking

Yet another useful feature, Lint checking in Android Studio 3.2 lets you easily find the common code problems, whether it be a minor usability issue or high-risk security vulnerability. It can call out unnecessary whitespaces, or deprecated APIs, and suggest you the newer ones. Lint checking also ensures that your Java and Kotlin code are compatible, your Slices are constructed properly, and more.

Emulator Snapshots

If you’ve ever wanted to open up your emulators in a specific state, like an opened application, you now can. Google introduced Emulator Snapshots which gives you an ability to save the states of the emulator. It can currently save opened applications and their data and some settings.

Many more

All of the features above are just the ones that I deemed major enough to explain in detail. Android Studio 3.2 includes much more features, including:

  • Bundled Kotlin 1.2.61
  • Improvements from IntelliJ IDEA 2018.1.6
  • Backward compatible Data Binding V2
  • Once experimental D8 desugaring is now stable and turned on by default
  • New code shrinker (R8)
  • ADB Connection Assistant to help you set-up and use the device over Android Debug Bridge
  • Syntax highlighting and code completion
  • IntelliJ’s Code reformatting
  • Safe refactoring

All of these features are detailed in the full release notes.

Conclusion

I think that Android Studio 3.2 is one of the most important updates to the IDE so far. Not only does it include a lot of new features to help you build some amazing applications, but it also helps you make them as stable as possible. You can now develop some great applications for Android Pie, use the profilers to see how they perform, check how correct and secure your code is, see if you use any deprecated APIs and replace them with the newer ones, and last but not least, test your application in the new updated emulator or on your device via new ADB Connection Assistant. Make sure to check the “What’s new” assistant after updating to Android Studio 3.2 to have the full picture of what the latest and greatest version of the IDE brings.

HostGator Web Hosting

0 comments:

Post a Comment