I'm working on android app that's running up against the dex method count limit. Is there a simple way to show the method count grouped by package? I can get the total method count, but my app has multiple components and I'm trying to figure out which component is the biggest contributor to this.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
I've written a
dex-method-counts
tool that outputs per-package method counts faster and more accurately than the smali-based tools referenced in JesusFreke's answer¹. It can be installed from https://github.com/mihaip/dex-method-counts.[1] that script disassembles the .dex and re-assembles it by package, but this means that methods that are referenced by multiple packages are counted twice
Piling on to an old question, I've written a Gradle plugin that will report the number of methods in your APK on every build. It uses the same DEX parsing code that the AOSP project uses. You can find it at https://github.com/KeepSafe/dexcount-gradle-plugin.
I appreciated the work off all developers above and I am always happy to have such great community, but since Android studio 2.2 Google team has released APK Analyzer -> https://developer.android.com/studio/build/apk-analyzer.html
Now we all have build in tool to analyze out methods count, our resources size and even we can compare two .apk files agains each other. Finally we all have this tool build in. Android development is coming to be easier and easier.
BTW: To find how much methods you have, open your .apk file in Android Studio (support 2.2+ only) and click on the classes.dex file. After that you will be able to see the methods count in all libraries and in your project as well.
I and a collegue published the last month a service that can help you with your purpose: http://www.methodscount.com/. It shows the methods count and other neat information
Under the hood we use
gradlew
to get the dependencies and the Android SDK tooldx
to calculate the dex information. We apply the procedure recursively to the library and its dependencies. We also persist the results for the already computed libraries so to speed up the process on consequent requests.If you use Android Studio or IntelliJ, you can just install the plugin to have all the information as an handy hint (the plugin uses the service as well).
You can also try using https://github.com/KeepSafe/dexcount-gradle-plugin which allows you to see the method counts per package graphically through an html.
This will give you an idea of how much each package hierarchy contributes to the method count. The results include all classes in that directory/package and all subdirectories/packages.
This slightly modified version is similar, except that it is only for the classes in that particular directory/package, not including any subdirs/subpackages