Android Learning Android Studio TraceView and lint tools use specific explanations

Source: Internet
Author: User

The last time I talked about the usage configuration of Android Studio terminal, I learned about the use of TraceView and lint tools today.

First of all, lint:

The Android Lint tool is a code hinting tool integrated in Android Studio. It is primarily responsible for optimizing your code, including XML and Java files, which are very powerful.

Write the code in time for lint test. will make our code very canonical and avoid code redundancy.

Let's find out the hidden problems in the code in time.

For example: We create a global variable in our code. This variable actually does not need the overall convenience. Lint will prompt us to change to local variables after checking. This is a very powerful means of promoting memory optimization.

How to use:

Can see inspect code, translation is a test

Click Select Whole project (the entire project) to

Effects such as the following:

Here hint ImageView not join ContentDescription attribute, has solved the method, really is very intelligent. Very powerful.

Clean code will help us detect any suspicious code.

Android Lint is talking about this.

Use of Android TraceView:

Traveview is a performance optimization tool for Android Studio integration, and it is believed that many people know it, but it should not be used much. It's more complicated to use. It should be said that understanding is more complicated. It mainly calculates the time taken by the method operation in the project. The number of calls to optimize app run efficiency.

For example: A method that takes longer, but has fewer calls. So you're going to have to test where this method is taking time, and for what reason?


Open Android Device Monitor, which everyone knows

1. Select the process you want to debug.
2. Click Start Mothod Profiling to turn the icon black.
3. Select Sample Base Profiling

Here's what you need to explain:

Trace Base Profiling

Overall monitoring, the project all the methods will listen, resource consumption is relatively large.

Sample Base Profiling

Sample monitoring, sampling at the specified frequency. Generally do not exceed 5s, it takes a long time to obtain accurate sample data.

When you click Start Mothod profiling again, a test sample is generated.

Effects such as the following:

The upper part is the time axis, the x-axis represents time, and the black area can be enlarged. Each region represents the elapsed time of each method.

The y-axis represents each individual thread.

The next section name is the performance analysis represented by the color block you selected.

Different colors, representing different methods. The color length represents the elapsed time.

Property Description:

Incl CPU time: A method consumes CPU (parent + child)
EXCL CPU Time: A method itself consumes CPU times (parent)

Incl Real time: How long a method really runs (parent + child)
EXCL Real Time: A method itself runtime (parent)

Of course there is a percentage of the corresponding, just more introduction.

And the number of Calls+recurcall calls + recursive calls

There's something more important:

CPU Time/call: The average per call consumes CPU time.

Real Time/call: The average time to run per call.

I think the number of references is very important.

With each method open, paents and children (that is, the parent and child methods) are displayed. and the elapsed time respectively.

Having said so much, we should be very clear about how to use TraceView.

Let's get here.

Android Learning Android Studio TraceView and lint tools use specific explanations

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.