ITZone

Statistics of the amount of methods used in the .apk file

This is my first post on viblo, in this first series I want to share with everyone how I use the library in android as well as optimizing each library to use. Using libraries written by other programmers is completely normal and convenient, but using too many libraries often makes a lot of difficulties in managing code, optimizing code, and maintaining fixbug later. This is why it is necessary to optimize libraries right from the beginning to make the best use. With my experience in the series of lib, I will share some articles as follows:

The first article I will introduce about the tool is very nice to use the dex mothod count.

General introduction :

Dex method count is a fairly simple tool that statistics the number of methods used in an apk file after it is finished. Perhaps many of you wonder: "why do I have to count the number of methods to do?", Or "what method should I use, what do statistics do?", Currently Android has a majority dev on Android studio studio. pretty good suport for build -multi-dex but error

It's a bug that haunts me (and probably lots of android devs using eclip). The above bug handling is quite complicated because it has to be optimized for the source code, reducing the amount of method load so that eclip can build okie, so this tool method count supports dev a lot in statistics, as well as the system of source code of me

Instructions for installing and using

(You can get source code as well as detailed instructions on github at https://github.com/mihaip/dex-method-counts ).

For example :

Then on your cmd screen will show the statistics of method numbers

For example

Also you can change some logic in main.java file, output.java so that you can output the result to file or change the method tree structure as you want. (This custom problem I think you discover yourself would be much more fun and interesting :). )

Conclude

There is this tool in hand now you try to create a small android project with only 1 simple view, in which import 2 sets of libraries: android suport.v7, and google play service. (Try using this tool to see how many methods your library has on your library, compared to the 65k method max that eclip can build for you, there will be a big surprise: D.) How unexpected, and how to solve it I will answer more carefully in the following article: Optimize google play service library . We hope you support: D.

ITZone via Viblo

Share the news now