Yesterday's Google I/O keynote gave an introduction to some of the great new improvements to Android Studio 2.2, but it only scratched the surface. Today, the Android Tools Team took to the stage again to detail even more about the things they've been doing to make work easier for developers. Topics ranged from new tools like the APK Analyzer and Espresso Test Recorder to big improvements in the code editor and inspectors. We can't cover everything, but here is a summary of the main topics presented today.
New Layout Editor
One of the two hot topics introduced during the keynote is a brand new layout editor. While the headlining addition is the new Constraint Layout container (we'll get to that shortly), there are a stack of useful new features that make the layout editor very fast and powerful. To begin with, it is not restricted to just layout files, menus and preference files are also supported.
While editing in the main view, a properties editor is available on the right side with a selection of the most important properties. A toggle is located at the top for switching between this view and a list of all known properties for the selected element. Many fields won't just show the current values set on an element, but they can also show inherited information from themes (likely a continuation of the theme editor).
There's also a handy Blueprint Mode that hides all of the visuals from controls and exposes just the structure and bounding boxes for a layout. This makes it easier to identify when a container or control isn't sizing the way it's meant to.
The Constraint Layout is where most of the excitement is at. It's a new container type found in the Android Support Library, supported all the way back to Gingerbread. The new layout editor is designed to take full advantage of the ConstraintLayout to position elements and generate proper layout code so everything works seamlessly for developers. Generated xml is clean and readable, so it will be easy to work with by hand if necessary.
ConstraintLayout is similar to RelativeLayout, but it supports even more positioning rules and guidelines. This makes it possible to significantly reduce or even eliminate situations that would have previously called for nested containers. Each layer of nesting in a layout has a significant impact on performance, so many developers may be able to speed up their apps and cut down on power requirements just by switching to ConstraintLayout. The Tools team even built a converter that can flatten out some existing layouts by replacing them with ConstraintLayout.
Espresso Test Recorder
The other hot topic from the keynote was a brand new test recorder that can capture live interactions with an app and generate usable Espresso test code. This feature is so simple it hardly requires more explanation than that.
The recorder can be launched from Run –> Record Espresso Test. This will build and run the current project on a device or emulator. Each action (e.g. taps, swipes, button presses) from that point on in logged. At any step along the way, an assertion can be added to check that the state of the app is where it is expected to be – these are the tests. Once all of the steps are finished, the recording can be saved and replayed on an emulator, a physical device, or sent to Google's Cloud Test Lab for testing across many different hardware configurations.
Other New Tools
Some smaller tools were also added in this release to tackle some otherwise time-consuming and confusing tasks. There's an APK Analyzer that can be used to skim through resources in an apk and check out how much space different files are taking. It can also look into .dex files to help with counting references and methods that contribute toward the infamous 64k reference limit. This can be useful for determining if it's possible to cut down on references or if it's easier to switch to multidex.
A manifest editor was added to show where certain things are coming from after a final manifest file is built. Since libraries can add numerous things on their own, this is especially helpful for pinning down the source of permissions.
There's also a project underway to rewrite the Project Structure Dialog. It will be able to generate and configure gradle files, hopefully eliminating the need for developers to do the same task themselves. It is currently focused on dependency management, like pointing out that a new version is available and making adjustments to the script. It can also browse child dependencies for a library and offers a search feature for tracking down new libraries. This is still considered experimental and must be enabled in settings to try it out. It's expected to be finished in Android Studio 2.3.
The IDE and code editors have also been given quite a bit of attention, largely thanks to an update to IntelliJ 2016.1 and CLion. Take a look at the JetBrains blog post for more details. The on-stage demo pointed out support for bidirectional strings, but there are dozens of new features and enhancements. Both JetBrains and Google have also added a lot of new inspections for numerous languages, and Android in particular.
Google also put a lot of effort into Firebase Integration, but the most visible feature is a plugin with step-by-step guides and sample code for common tasks. There's also a "Firebase Test Lab" for running applications on specific hardware and software configurations to track down unique bugs.
If you're just looking for the right way to use a particular class, there's a new "Find Sample Code" menu option on many standard classes that will pull up sample code from the Android SDK samples (and possibly other sources).
Some new code annotations have been added, including: @AnyThread, @RequiresApi, @Px, and @Keep. There may be more, but those were specifically noted on stage. There's also a new command called "Infer Annotations" under the Analyze menu. It examines code and makes assumptions about annotations that might belong based on usage. Ultimately, this could help with catching mistakes or potentially problematic situations.
Another work in progress tool is underway with the intention of helping developers with migrating code to the Android M Permission model. It should be able to inject boilerplate code to handle requests and different outcomes. Details were scarce, but it should be useful once it's further along.
There is also a new refactoring tool that can remove unused resources, thus cutting down on app size and cleaning up code.
Google is working to give C++ developers plenty of room to get things done, too. As previously noted during the keynote, external build systems are now supported, which means it's possible to shrug off gradle and use CMake or NDK Build instead. In other words, there's no need to waste time porting between very different build systems, especially since CMake is generally better suited to do the job.
There is also a new project wizard in the works that will make it easier to add C++ code to new and existing projects, so it will be much easier to mix and match code.
Check out the video below to see demonstrations of everything described above and get a rundown of the ideology behind some of the decisions and goals of the Android Tools Team. It's well worth a viewing.