Google I/O brought us a preview of the next major release in the form of Android Studio 2.2 Preview. This release is a large update that builds upon focus to create a fast and productive integrated development environment (IDE) for Android.

Some of the major & useful features which are added in this version are as follows :

  • Instant Run :

    IDE swaps your code changes in one of three ways :

    • For incremental changes : Hot Swap (Fastest)
      Used by IDE when changes are done in code. Android Studio 2.2 redirects code path to pickup changed the code.
    • Activity Restart : Warm Swap
      Used by IDE when there are resource changes
    • Restart App : Cold Swap
      Used by IDE when there are any structural changes (Ex. Change of inheritance, or change in method signature)
IDE versions Cold Swaps Warm Swaps Hot Swaps
2.0 1 1 1
2.1 4.7X faster 10.7X faster
  • Android Studio includes change in AAPT which gives us New and Enhanced AAPT in Android Studio 2.2 Before Studio 2.2, on changing resource or adding new resource AAPT was renumbering all resource Ids. So on a code change, we were getting Cold Swap instead of Hot Swap. New AAPT will hold all resource Ids as constant. So, Android Studio 2.2 will allow more Hot Swaps instead of Cold Swaps.
  • Split APK is a new way of building on building App which is used in Studio 2.2. On building App, Studio 2.2 will break your app in 11 to 12 dex files and when full build id done, Studio 2.2 actually only rebuilds changed the code.
    Above two will help to improve build speed for Android Apps on Android Studio 2.2.
  • Visual Editor/ Layout Editor :

    Drag-and-Drop widgets from the palette to the design surface or the component tree view of your app. Drag-and-Drop will be available for Menu files, Preference files which will ease our work while designing XML for these.

    Properties panel will show a set of properties for quick widget edits with a full sheet of advanced properties one click away.

    android_studio_2.2_preview_1

    On Design Surface, we have Blueprint Mode and Design Mode. Blueprint mode is basically X-Ray mode of Design Mode. This mode is particularly useful for new Layout added which is Constraint Layout. Following topic will help to understand about Constraint Layout

  • Constraint Layout :

    Constraint Layout is a new flexible layout manager for your application.

    It allows you to create dynamic user interfaces without nesting multiple layouts.

    Constraint Layout looks like RelativeLayout but it can more efficiently express your app design than other layouts.

    Constraint Layout allows you to define the relation between views or group of views in your layout.

    By this, you can create more complex User Interfaces without nested layouts. This will improve your app’s performance

    Android Studio 2.2’s New Project wizard uses Constraint Layout as default layout for many of its project templates.

    In addition, to convert any layout to Constraint Layout with Android Studio 2.2, select Design Tab, right click on layout, and select Convert to Constraint Layout from a context menu.

    To add support, need to add dependency under gradle as below :

    compile ‘com.android.support.constraint:constraint-layout:1.0.0-alpha2’

    Drag drop feature is applicable for this layout.

    Auto-connect Mode is also available which will add all constraints for you on drag and drop UI widget.

    android_studio_2.2_preview_2

    Constraints will have strengths which will be displayed in percent on screen.

    Also, you can remove all constraints if not needed just by clicking.

  • Layout Inspector :

    As a developer, many times we need to analyze UI layout rendering. Layout Inspector will do that for you. Using Layout Inspector, one can debug a snapshot of app layout running on the Android Emulator or device. Inspect the view hierarchy and corresponding attributes.

    To capture a snapshot from an emulator, make sure that layout will be visible on emulator or Device.

    From Android Studio, click Android Monitor and select Layout Inspector tab for inspecting layout rendering.

    Follow image added below.

    android_studio_2.2_preview_3

  • Firebase Plugin :

    Firebase is a platform that helps you to develop high quality app. Firebase gives you the tools and infrastructure from Google to help you develop, grow and earn money from your app. In Android Studio 2.2, Assistant tab is available, which will help the developer to take a drill for multiple features which comes under it. To add Assistant tab select Tools and click on Firebase.

    android_studio_2.2_preview_4

    This plugin will allow every developer to add services with few clicks.

    Some of the Services are as follows :

    • Cloud Messaging
    • Crash Reporting
    • AdMobs
    • Analytics
    • Real-time Database
    • Test Lab
    • App Indexing
  • Code Sample Browser :

    Android Studio 2.2 provides a plugin which will allow users to access Google Android code samples. Till now, developer has to refer Sample Codes which are added in Android SDK folder. After analyzing these Sample Codes, developer has to start working on referred module in a current application. Code Sample Browser helps Android Studio to merge these two references. All sample codes will now be available in Android Studio.

    To get access to Sample Codes, double click to highlight a variable or type or method from code and right click to get menu. Click on Find Sample Code option to get details. Follow Image added below.

    android_studio_2.2_preview_5

  • Merged Manifest Viewer :
      • Addition to the current version of Android Studio, now we will get added option for a manifest file which is Merged Manifest.
      • This tab will give a better idea about how manifest merges with app dependencies for all project build variants.

    android_studio_2.2_preview_6

  • Improved C++ Support :

    Android Studio 2.2 improves C++ development with the ability to edit, build and debug pre-existing Android projects that uses ndk-build or CMake rather than Gradle. Additionally, the existing lldb C++ debugger is now even better with project type auto-detection and a Java language aware C++ mode that lets you use a single debugger process to inspect both Java language and C++ runtimes.

  • Espresso Test Recorder:

    This tool will help testers who gets irritated with writing long and repetitive UI tests. With Espresso Test Recorder, testers can record or create by interacting with application on Emulator or Android Device. Android Studio will take care of capturing UI interactions and convert them to Espresso Test. We can run those tests on local or Firebase Test Lab. No extra efforts are required to write UI tests after this.

    To use the Espresso Test Recorder, select Run menu and click Record Espresso Test. This will restart Application and open new window for recording your tests. Under this window all recorded tests are added as we keep on interacting with UI.

    android_studio_2.2_preview_7

  • APKAnalyser :APKAnalyser is used to get into app apk file. This tool will help you to find download size and what is taking more memory.

    Select Build from Studio Main Menu and click on Analyse APK option. You can scan any apk file by selecting a path from file explorer.

    android_studio_2.2_preview_8

    For now, Android Studio 2.2 is available in Canary version.

    You can download Android Studio 2.2 Preview from canary release site.

By-
Rahul Pawar
Technical Lead – Mobisoft Infotech Pvt. Ltd