Android studio 4.1 released to enhance the development experience in all aspects

Time:2020-10-25

Android studio 4.1 released to enhance the development experience in all aspects

We’re happy to release itAndroid Studio 4.1Stable version, for you to bring a series of common editing, debugging and optimization functions. One of the key appeals of version 4.1 is to help you useAndroid JetpackLibrary (i.e. Android development library suite) follows best practices and improves code writing efficiency. Based on your feedback, we have directly integrated many commonly used Android libraries in the IDE, thus improving the experience of writing code.

Some of the highlights of Android studio 4.1 are as follows: the introduction of a new database inspector, which is used to query the application’s database; support browsing using dagger orHiltIt supports the use of tensorflow Lite model in Android projects, which further enhances the support of machine learning on the device side. We also updated apply changes to speed up deployment. Based on your feedback, we have made some changes and introduced a new native memory performance analyzer and independent analysis tool to help game developers.

Product quality remains a major focus of the team and we have been working hard to resolve errors and performance issues. From your feedback, many developers agree with our focus on improving performance and reliability. I’m glad to tell you that in this release cycle, we fixed 2370 errors and solved 275 public problems. High quality is our goal, because we know that it is the key to improve the efficiency of developers.

Many users have provided early feedback in the preview, and I would like to thank you. It is with your feedback that the features in Android studio 4.1 can be iterated and improved. If you’re ready to use this new stable version and increase your productivity with a whole new set of features, you candownloadAnd start using it.

Here is a list of all Android studio 4.1 by key development processesnew function

Design

Material design component update

Now, the Android studio template in the New Project dialog box uses the material design component (MDC), and supports the latest version of the theme and style design guide by default. This makes it easier for developers to use the recommended material style patterns and support modern interface features such as dark themes.

Android studio 4.1 released to enhance the development experience in all aspects

Material design component update in project template

Updates include:

  • MDC: Project usagebuild.gradleMediumcom.google.android.material:material。 Basic application theme usageTheme.MaterialComponentsParent, and override the updated MDC color and “on” attribute.
  • Color resourcescolors.xmlColor resources in use literal names (for example, usingpurple_500Instead ofcolorPrimary)。
  • Theme resources: theme resources are located inthemes.xml(rather thanstyles.xml)And useTheme.<ApplicationName>Name.
  • Dark theme: basic application theme usageDayNightThe parent is divided intores/valuesAnd res/values-night
  • Subject properties: refers to color resources as theme properties in layout and style (for example?attr/colorPrimary)To avoid hard coding colors.

development

Database Inspector

We hope to simplify the operation of checking, querying and modifying the application database with the help of the new database inspector. First, deploy your application to a device running API 26 or higher, and then select from the menuView > Tool Windows > Database Inspector。 Whether your application directly uses the jetpack room development library or SQLite on Android platform, you can now easily check the databases and tables in running applications, or run custom queries.

Since Android studio maintains a real-time connection when you check the application, you can also use the database inspector to modify the values and view the results in the running application. If you use the room persistence library, Android studio also inserts a run button next to each query in the code editor to help you quickly run queries defined in the @ query annotation. You can readOfficial documentsLearn more.

Android studio 4.1 released to enhance the development experience in all aspects

Use database inspector to check, query and modify the application database

Run the Android simulator directly in Android studio

Now you can run the Android emulator directly in Android studio. This feature helps save screen space, and you can use hotkeys to quickly navigate between the emulator and editor windows, and organize your IDE and simulator workflow in one application window. You can manage common emulator operations such as snapshots and rotations and screenshots in studio, but you still need to use a stable emulator to use the full functionality options. You can use this menu path to enable this feature:File → Settings → Tools → Emulator  → Launch in Tool Window

Android studio 4.1 released to enhance the development experience in all aspects

Running Android emulator in Android studio

Dagger navigation support

DaggerIs a common dependency annotation library on Android. Android Studio provides a new gutter operation and extends the support in the find usages window, making it easier to navigate between dagger related codes. For example, click next to the method that uses the given typeAndroid studio 4.1 released to enhance the development experience in all aspectsThe gutter operation navigates you to the location that provides the type. Instead, clickAndroid studio 4.1 released to enhance the development experience in all aspectsThe gutter operation navigates you to where the type is used as a dependency. Android studio also supports the use of jetpack forHiltLibrary defined dependencies perform navigation operations. You can readOfficial documentsLearn more.

Android studio 4.1 released to enhance the development experience in all aspects

Use the gutter operation to navigate between dagger related codes

Using tensorflow Lite model

At present, Android developers are using machine learning to create novelPractical experienceTensorFlow LiteWe hope to simplify the process of importing these models into Android applications. Like view binding, Android studio generates easy-to-use classes to help you streamline the code needed to run the model and improve type security. The current implementation of ML model binding supports image classification and style transformation models as long as they are enhanced through metadata.

To view details of the imported model and how to use it in your application, double-click the. Tflite model file in the project to open the model viewer page. You can readOfficial documentsLearn more.

Android studio 4.1 released to enhance the development experience in all aspects

△ view tensorflow Lite model metadata in Android studio 4.1

Build and test

Android simulator folding device hinge information support

Android Studio

Except for the recently added5g mobile network testWe also added support for foldable devices in the Android simulator. In Android emulator 30.0.26 and later, you can set up foldable devices using a variety of folding designs and configurations. After setting, the simulator will provide the hinge angle sensor and attitude change information, so that you can test the response of these models. Please refer to the blog post [developing on Android 11 using Android simulator](https://medium.com/androiddev…
)》Learn more.

Android studio 4.1 released to enhance the development experience in all aspects

Apply changes update

Faster builds help developers change applications more easily and quickly. To help you improve the efficiency of application iteration, we have made several enhancements to apply changes for Android 11 or later devices.

We have invested heavily in optimizing iteration speed to develop a way to deploy and save changes on devices without installing applications. Now, after the initial deployment is completed, the speed of subsequent deployment of Android 11 devices through apply code changes or apply changes and restart activity has been greatly improved. We’re still in apply changesAdded support for other code changes。 Now, after you add a method, you can deploy the changes to the running application by clicking the apply code changes or apply changes and restart activity button.

Exporting C / C + + dependencies from AAR

Android gradle plugin 4.0 addedImport prefab package into AAR dependencyThe function of. We want to extend this feature to share native libraries. AGP 4.1 supports exporting libraries from external native builds in AAR of Android library project. To export native libraries, add the following to the library project build.gradle In the Android block of the file:

buildFeatures {
    prefabPublishing true
}

prefab {
    mylibrary {
        headers "src/main/cpp/mylibrary/include"
    }

    myotherlibrary {
        headers "src/main/cpp/myotherlibrary/include"
    }
}

Symbolic analysis of native code crash report

When native code crashes or anr occurs, the system generates a stack trace, which is a snapshot of the nested function sequence called before the program crashes. These snapshots can help you identify and fix problems in source code, but you must first symbolize them to translate the computer address back to a human readable function name.

If your application or game is developed with native code such as C + +, you can now upload the debug symbol file of each version of the application to the play management center. The play admin center uses these debug symbol files to symbolize the stack traces of your application, simplifying crash and anr analysis. If you want to include debug symbols in the app bundle, add the following to thebuild.gradleIn the document:

android.buildTypes.release.ndk.debugSymbolLevel = 'SYMBOL_TABLE'

optimization

System trace interface improvement

In Android studio 4.1, weSystem TraceThe optimization tool can let you know the usage of system resources by application in real time. The marquee mode also makes it easier to select trace records. In addition, we have added a new analysis tab and added more frame rendering data to help you investigate rendering problems in the application interface. You can readOfficial documentsLearn more.

Box selection: in the threads section, you can now drag the mouse to frame select a rectangular area and click the zoom to selection button in the upper right corner (or use the keyboard shortcut m) to zoom in on the area. When you drag and drop similar threads together, you can box across multiple threads to check all threads at the same time.

Android studio 4.1 released to enhance the development experience in all aspects

△ it is easier to select tracking records by using the frame selection mode

Summary tab: the new summary tab in the analysis panel displays the following:

  • Summary statistics for all instances of a specific event, such as instance count and min / max duration.
  • Trace event statistics for the selected instance.
  • Data about thread state distribution.
  • The longest running instance within the selected trace event.

Android studio 4.1 released to enhance the development experience in all aspects

△ view summary statistics in the summary tab

Display dataIn the display section,SurfaceFlingerAndVSYNCThe new timeline of can help you investigate rendering problems in the application interface.

Independent analyzer

The Android studio analyzer can now be accessed in a separate window independent of the Android studio main window. This feature is useful when optimizing Android games built with other tools such as unity or visual studio.

To run a stand-alone analyzer:

  1. Make sure your system is not running the analyzer in Android studio now.
  2. Go to the installation directory and navigate to the bin directory:

Windows/Linux

 <studio-installation-folder>\bin

macOS

 <studio-installation-folder>/Contents/bin

  1. Depending on your operating system, runprofiler.exeOrprofiler.sh

Stand alone analyzers can be connected to Android emulator or other connected devices.

Android studio 4.1 released to enhance the development experience in all aspects

Use independent Android studio analyzer to optimize your application

Native memory performance analyzer

Tracking native memory usage is very important for game developers and other developers using C + +, who can optimize the memory usage of their applications. Android studio memory profiler now includes a native memory profiler, which is designed for applications running on Android 10 or later physical devices. Native memory performance analyzer can track the allocation / destruction of objects in native code in a specific period of time, and provide information about overall memory allocation and system heap remaining size.

To start recording, click on theRecord native allocations:

Android studio 4.1 released to enhance the development experience in all aspects

Use native memory performance profiler to check native memory allocation

summary

Briefly reviewed, Android studio 4.1 includes the following new and improved features:

Design

  • Material design component update

development

  • Database Inspector
  • Run the Android simulator directly in Android studio
  • Dagger navigation support
  • Using tensorflow Lite model

Build and test

  • Android simulator folding device hinge information support
  • Apply changes update
  • Exporting C / C + + dependencies from AAR
  • Symbolic analysis of native code crash report

optimization

  • System trace interface improvement
  • Independent analyzer
  • Native memory performance analyzer

Author / Scott swarthout, product manager

The information is not sponsored by or associated with unity technologies or its subsidiaries. “Unity” is a trademark or registered trademark of unity technologies or its subsidiaries in the United States and other regions.

Recommended Today

Java security framework

The article is mainly divided into three parts1. The architecture and core components of spring security are as follows: (1) authentication; (2) authority interception; (3) database management; (4) authority caching; (5) custom decision making; and;2. To build and use the environment, the current popular spring boot is used to build the environment, and the actual […]