Several useful new features in Android Studio 2.2

Hello viewer, You can now have our Tutorial Lessons in your android mobile device and read it offline.
Download kotlin Programming APP on PlayStore
Download Website SEO Lessons APP on PlayStore

Android Studio 2.2 preview provides several new toys, very useful, as follows:

  • Espresso Test Recorder
  • Dependencies Management
  • APK analyzer
  • View the merged sources for AndroidManifest.xml

Espresso Test Recorder

Espresso is a UI unit testing framework, Test Recorder is the name suggests is used to record UI unit testing tools, it contains a few functions:

  • Record the interaction of the UI on a real machine or simulator
  • You can add assertions during recording
  • Generate Espresso unit test code, which can be done on the basis of the second development

In google samples of android-topeka example, to see how to record unit tests.

  1. Run-> Record Espresso Test

    Several useful new features in Android Studio 2.2 - Several useful new features in Android Studio 2.2 - Several useful new features in Android Studio 2.2 -

    Click on the toolbar above, the terminal will appear in the selection window.

  2. In the real machine or run on the simulator

    Several useful new features in Android Studio 2.2 - Several useful new features in Android Studio 2.2 - Several useful new features in Android Studio 2.2 -

    Select the terminal device to run well, the app will run, then you can start the UT recording.

  3. Start recording the UT

    Several useful new features in Android Studio 2.2 - Several useful new features in Android Studio 2.2 - Several useful new features in Android Studio 2.2 -

    After the app is run, a recorded window will appear, showing the flow of UI interaction and the two buttons “Add Assertion” and “Complete Recording”. Next, start interacting, enter First Name and Last Initial, and select the picture, then the operation flow as shown below:

    Several useful new features in Android Studio 2.2 - Several useful new features in Android Studio 2.2 - Several useful new features in Android Studio 2.2 -

    Click the OK icon in the lower right corner to enter the next screen.

  4. Add assertions

    Several useful new features in Android Studio 2.2 - Several useful new features in Android Studio 2.2 - Several useful new features in Android Studio 2.2 -

    Click Add Assertion to add assertions during recording. Here, I added two assertions, one is to assert that the avatar region has been normal display, and the other is to assert the account area shows the text as “geniusmart T”.

  5. Complete the recording and generate the UT code

    Several useful new features in Android Studio 2.2 - Several useful new features in Android Studio 2.2 - Several useful new features in Android Studio 2.2 -

    Click “Complete Recording” to complete the UT recording, and generate the code.

    Several useful new features in Android Studio 2.2 - Several useful new features in Android Studio 2.2 - Several useful new features in Android Studio 2.2 -

    We can do this second development based on this code, write some tools can not help us to generate assertions.

  6. Multiplex UT
    After the recording, the entire recording process will be in the form of code androidTest folder, we can repeatedly run UT, verify the accuracy of the code.

Espresso Test Recorder recording function and the second development, greatly improving the efficiency of writing Espresso UT. Even if you are not familiar with Espresso’s syntax, you can still write unit tests with higher coverage.

Also to be emphasized that, Espresso solved test View layer to MVP is, View layer depends on the Model layer and layer Presenter, the View layer if you need to initiate a network request, UT record is full of uncertainty, because you are not sure whether the normal response to network requests, and in response to what the result is, therefore requires additional layers of network requests and do some similar problems Mock or Fake.

Dependencies Management

Google is rewriting the project structure dialog box, used to resolve the project dependencies, and do a more friendly show.

  • The Project Structure window opens

    Several useful new features in Android Studio 2.2 - Several useful new features in Android Studio 2.2 - Several useful new features in Android Studio 2.2 -

  • View the dependencies that are updatable

    Several useful new features in Android Studio 2.2 - Several useful new features in Android Studio 2.2 - Several useful new features in Android Studio 2.2 -

    In the Messages panel, you can view all dependencies within the application and automatically identify the local repository and / or the remote jCenter repository for newer versions. Through the “Update All” button to update all dependencies.

  • View all dependencies and delivery dependencies

    Several useful new features in Android Studio 2.2 - Several useful new features in Android Studio 2.2 - Several useful new features in Android Studio 2.2 -

In the “Dependencies” panel, we can see all the Dependencies of the Module and pass dependencies, very convenient. In the past, we can only use the command line gradlew dependencies to view dependencies.

Note: The screenshots in this section are from the “What’s new in Android development tools” theme of Google I / O, and in the latest version of the AS preview (either window or mac) 2.2 preview version of the introduction of the document did not formally introduce the function, so it is estimated that some time to experience.

APK analyzer

Google in the development of Instant Run, in order to clarify the internal mechanism of the APK file, developed a new tool APK analyzer.

  1. Build-> Analyze APK

    Several useful new features in Android Studio 2.2 - Several useful new features in Android Studio 2.2 - Several useful new features in Android Studio 2.2 -

    In the toolbar as above, select the apk file, you can view the apk analysis results, this section to chrome.apk example.

  2. View the file size

    Several useful new features in Android Studio 2.2 - Several useful new features in Android Studio 2.2 - Several useful new features in Android Studio 2.2 -

    In the analysis results, you can view the original file size and download size, which can provide data for our apk thin support, to help us locate the file size can be optimized or deleted.

  3. View the resource file

    Several useful new features in Android Studio 2.2 - Several useful new features in Android Studio 2.2 - Several useful new features in Android Studio 2.2 -

    In the res can view images and layout files.

  4. View the value table

    Several useful new features in Android Studio 2.2 - Several useful new features in Android Studio 2.2 - Several useful new features in Android Studio 2.2 -

    Click on resources.arsc, you can view string, color, layout, etc. ID value.

  5. View the dex file

    Several useful new features in Android Studio 2.2 - Several useful new features in Android Studio 2.2 - Several useful new features in Android Studio 2.2 -

    Click on the classes.dex file to see the number of methods declared and the number of methods referenced for each Java file.

View the merged sources for AndroidManifest.xml

App compiled, the list of documents will be much more than we write the code (such as the authority of the statement, the four components of the configuration, etc.), this part of the source code for a variety of dependent libraries.

The new version of the IDE provides the “Merged Manifest” feature to help us view the manifest file of the merger source.

Several useful new features in Android Studio 2.2 - Several useful new features in Android Studio 2.2 - Several useful new features in Android Studio 2.2 -

The figure above, you can clearly see the network access by the play-services-ads:8.4.0 dependency list provided by the library from the merger.

These small toys, especially the unit test recording and dependency management, are five-star praise, is very worthwhile in the project development practice. In addition, the 2.2 version also provides more friendly support for C + +, as well as visual layout blueprint mode, etc., look forward to the official version of the early arrival, but also look forward to Google for us to bring more and better and more fun new Features.

About The Author

Related posts

Leave a Reply