Accelerate optimization and analysis of Android applications, and discuss launcher optimization.

Source: Internet
Author: User

Android application Development uses the Java language, Java is the development threshold is relatively low, the operation efficiency is low, the developer's quality difference is relatively big. Makes Java program development easy, optimization and maintenance more difficult. Personally think that the core of Java is the automation of memory management and cross-platform, but its criticism is also in this piece, as to efficiency, with the development of hardware, more and more people are no longer the focus of consideration. Many people will write Java programs, but not how to optimize the Java program, encounter memory leaks, encounter empty objects, encountered timeouts, encountered a probabilistic memory bug, often do not know. Because there are too many tools to solve these problems, it also shows that Java optimization is a worldwide problem, the appearance of the problem may be one, but the cause may be more than one, need to choose the right tool to find the problem point, using the wrong tool or two eyes flying blind. Unlike the C language of a memory, a stack debug can solve most of the program problems.

The company has a Woslauncher starter project, product managers understand the operation of the animation is not smooth, the development of colleagues engaged for one months, refactoring a lot of code, the effect is still not ideal. Get me here, optimize the Three Musketeers to open, immediately find the problem point, a few minutes later, the optimization effect immediately. I think the anroid optimization of the Three Musketeers is systrace,traceview,hierarchyviewer, these three tools can solve all my work in the optimization of the program.

I have no intention of refactoring other people's code, which takes too much time and does not want to review all the code of comrade of the project group, which also takes a lot of time. Use the tool directly.

1. First use the developer mode to bring the analysis UI performance using GPU over-rendering (developer mode, layout optimization)

Hardware acceleration, open the "Show Hardware layers Updates" option. (developer mode, turn green not accelerated)

Using the GPU rendering mode graph and the FPS to examine the performance of the UI, we find that the problem is not very big

2. Using Systrace study, after operation to obtain if the result, the red dot and yellow in the figure indicate that the system does not slip smoothly enough,

Click on the red dot using the M key, found that the problem is probably concentrated in three aspects, layout measure,cpu Delay,view OnDraw

3. Use the Hierarchyviewer tool to optimize the layout, look for performance problems with Measure,layout,ondraw, and then open it and discover that there is a performance problem with the Red Point view, and then find that the layout is on the shortcut. The final location is on Google's folder. He has two view, a OnDraw timeout, cost 1.234MS, a layout timeout, took 0.597 milliseconds, this Google folder, may need to find an alternative

Cannot map

3CPU Scheduling delay problem, generally indicates that the CPU is busy, this can be analyzed by traceview , crawl TraceView after analysis, get the following interface

Cannot map

This tool can show the execution time of all the functions in the app, in general, we need to optimize two kinds of functions, one is the number of calls, but each time the function is long, the other is that it takes time not long, but the number of calls very much, so that itself consumes a lot of time, the optimization method is mainly to refactor code, Modify the algorithm to find alternative solutions

Clicking on the CPU Time/call column allows the average time consumed by all functions to be sorted in ascending or descending order, and click Calls+recurcalls/total to get the total number of function calls and recursive calls and ascending or descending order, It is generally possible to skip directly to the function of the system that is not our app's custom class, and directly study our own package name Class name function.

Then found a time-consuming function createmediumdropshow function, this function uses the special effect, opened the Extractalpha, this is a time-consuming function. The createmediumdropshow itself consumes as much as 3.4% of the entire cycle fragment. Try to open the code optimization. After removing the effects or looking for alternatives, look again.

4. Open the Systrace tool to observe the results of the optimization, found that the yellow dots and red disappeared half.

5. Try to move the Google folder to the fixed bar, do not redraw the test with the animation, red warning all disappears

6. Further refine the yellow warning

7. Open TraceView, found that onmeasure become a time-consuming, and further use of the development model of the GPU over-rendering analysis, found that there are less serious over-drawing problems, icon under the Software name font is red, which is over-drawn flag. Slowly optimize

8 Open Hierarchyviewer Tool again analysis, red are problematic layout, find these layout files, remove nesting, optimize too huge picture, androidstudio for layout, will give a lot of useful suggestions. Run after optimization.


Accelerate optimization and analysis of Android applications, and discuss launcher optimization.

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: info-contact@alibabacloud.com 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.