Code editing and debugging quality are the focal points of just released Android Studio 3.6, which for example introduces view binding and a new packaging tool to the IDE.
To prevent Android developers from losing time with broken code, the team behind the project has introduced the concept of view binding to the current release. It promises “compile-time safety when referencing views in your code”, making null pointers and class cast exceptions a thing of the past – in this specific context at least.
All of this is realised by the generation of special binding classes for each XML layout file in a module, which can be used to access a view. Bound views in the binding class use their corresponding type, therefore avoiding incorrect casting, which is only one of the aspects making the approach come out on top when compared to findViewById, which was often used before.
Since finding memory leaks in a programme can be quite a challenge, the Studio’s memory profiler has been fitted with the ability to detect potentially leaky activity and fragment instances. The feature seems to come heavily requested and can be activated by ticking the suitable checkbox when working with a heap dump.
Devs keen on publishing their build artifacts to an Apache Maven repository, can do so now thanks to the newly included support for the Maven Publish Gradle plugin. Speaking of building, the Studio now uses zipflinger as the standard packaging tool for debug builds, which should speed up the process.
Proponents of the Kotlin programming language are now able to use Android NDK features to automatically create stub implementation functions for JNI declarations and find the implementation corresponding to a JNI declaration.
In terms of testing, the new version comes with a more current release of Android Emulator, which allowed the Android Studio team to spruce up the extended controls menu with an embedded Google Maps UI. The new addition helps with the saving and re-sending of individual points as virtual locations, as well as the route generation. Apart from that there is now preliminary support for multiple displays so multi-display setups can be properly tested
Meanwhile Android app designers are now able to see their design and code side by side, thanks to a new split view capability replacing preview windows. Other improvements that made it into the release supposedly help to make applying the colours defined as colour resources easier, resume interrupted downloads, and re-import APK files should a change have been detected.