Android development army vast, after nearly ten years of development, Android technology optimization day by day new, now Android 11.0 has been released, the performance of the Android system has been very smooth, can be fully comparable to iOS experience.

However, to the hands of the major manufacturers, to change the source code, custom system, so that the Android native system becomes mixed, and then to the hands of different levels of development engineers, because of the uneven technical level, even if many mobile phones in the running software performance is very high, open the application is still stuck.

In addition, as product content iterates and features become more complex, the UI pages become richer, which can become a barrier to smooth operation. To sum up, APP performance optimization has become a comprehensive quality that developers should have, and it is also a guarantee that developers can complete high-quality application works.

To this end, I put ali, Tencent, Bytedance, Meituan and other companies Android performance optimization practice integrated into a PDF document, due to too much content, I first introduce the practice part, and then introduce the theory part.

The project of actual combat

  • startup
  • fluency
  • The practice of Douyin in APK packet size resource optimization
  • Youku responsive layout technology full analysis
  • Network optimization
  • Mobile Taobao Double 11 performance optimization project revealed
  • Autonavi APP full link source code dependency analysis
  • Complete the OOM experience sharing
  • Wechat Android terminal memory optimization practice
! [](https://upload-images.jianshu.io/upload_images/24944255-fb8bbe216e72b287.png? imageMogr2/auto-orient/strip|imageView2/2/w/601/format/webp)

The above resources are free to share with you, the content is on the open source project: Github, you can get their own.

The theory of

In terms of Android application optimization, we mainly optimize from the following six aspects:

  • Optimization of startup speed and execution efficiency
  • Layout detection and optimization
  • Memory optimization
  • Optimize the power consumption
  • Network transmission and data storage optimization
  • APK size optimization

Optimization of startup speed and execution efficiency

  • Cold startup and hot startup This section describes the startup mode, features, and application startup process, measures the startup time of an application, reduces the startup time of an application, and optimizes the startup experience.

  • Solution 1: Change the background of the white screen to a picture; Solution 2: Make the startup white screen background transparent.

  • APP stuck problem analysis and solution 16MS principle; Caton treatment; Triple Buffer. Since frame loss is inevitable, the Android team never gave up on optimizing this area, hence Triple Buffer.

  • StrictMode StrictMode details, Systrace and TraceView

! [](https://upload-images.jianshu.io/upload_images/24944255-a718b7bafbc35a7c.png? imageMogr2/auto-orient/strip|imageView2/2/w/668/format/webp)

Second, layout detection and optimization

  • Each component and Layout of the Layout hierarchy optimizer needs to be initialized, laid out, and drawn, and if the Layout is nested too deeply, the loading operation can be more time-consuming and, in worse cases, can run out of memory. In this section, learn to use two tools to check and optimize layouts.

  • Overrender if you can know the number of overrenders from the system Settings, you can read the value when testing and fill in the report. Why automate it? In the system test of APP, it is found that there are a lot of pages, such as more than 20 pages for the first and second levels of housekeeping, and the integration package, gray package, formal package and regression package all need to be tested once, so it is necessary to read the automatic overrendering count.

! [](https://upload-images.jianshu.io/upload_images/24944255-e06573e0d3a1455e.png? imageMogr2/auto-orient/strip|imageView2/2/w/659/format/webp)

Third, memory optimization

Due to the Sandbox mechanism of Android applications, the amount of Memory allocated for each application is limited. If the Memory is too Low, the Low Memory Killer (LMK) mechanism will be triggered, which causes flash withdrawal. If you want to optimize memory, you need to understand how Java memory is allocated and recycled. For this, you can refer to the following content: How to locate, analyze and resolve memory leaks in Android applications

Mainly contains

  • Memory jitter and memory leakage
  • Large memory, Bitmap memory optimization
  • Profile memory monitoring tool
  • Mat large object and leak detection
! [](https://upload-images.jianshu.io/upload_images/24944255-e35512eabc26a7ed.png? imageMogr2/auto-orient/strip|imageView2/2/w/674/format/webp)

Fourth, power consumption optimization

If an app is rarely used but uses a lot of power, users will want to uninstall the app. So how to reduce their app power consumption is a very important thing.

What are the factors that consume electricity?

(1) Excessive Alarm Manager wakeup scans (2) Frequent use of local wakeup locks (3) Excessive background network usage (4) Excessive background WiFi scans are scans

Details include

  • Doze&Standby
  • Battery Historian
  • JobScheduler, WorkManager
! [](https://upload-images.jianshu.io/upload_images/24944255-1cbbe1fb1845965e.png? imageMogr2/auto-orient/strip|imageView2/2/w/671/format/webp)

Optimization of network transmission and data storage

  • Google serialization tool Protobuf
  • 7z limit compression
! [](https://upload-images.jianshu.io/upload_images/24944255-0fcfdc443aaa4f14.png? imageMogr2/auto-orient/strip|imageView2/2/w/665/format/webp)

6. APK size optimization

Keep our APK files as small as possible, remove unused code and resource files, save on downloads and improve efficiency.

  • APK thin body
  • Confusion principle of wechat resources
! [](https://upload-images.jianshu.io/upload_images/24944255-afb7628ec9aaad3b.png? imageMogr2/auto-orient/strip|imageView2/2/w/665/format/webp)

Well, I’ll just cover the core of Android performance optimization here, but it would be too long to cover development efficiency optimization.

The above resources are free to share with you, the content is on the open source project: Github, you can get their own.

At the same time, I also organized the “Android interview real question analysis complete PDF hd +②” Android interview knowledge system “learning mind mapping compression package —————— can be my [Github] reading download, finally feel helpful, in need of a friend can point a like

! [](https://upload-images.jianshu.io/upload_images/23587538-9bfec83357103cc1.png? imageMogr2/auto-orient/strip|imageView2/2/w/1200/format/webp)

! [](https://upload-images.jianshu.io/upload_images/23587538-f79dbdd26eeaa7be.png? imageMogr2/auto-orient/strip|imageView2/2/w/837/format/webp)