Do library dependency increase size of APK?

陌路散爱 提交于 2019-12-04 07:33:51

All three of those methods will increase the size of your APK. The difference between them is where does the source code reside:

  • A module dependency is source code on your local machine. It is compiled into bytecode when you build the app.
  • A JAR file is pre-compiled bytecode. It also is on your local machine, but it is not really source code. The bytecode is simply added to your own when you build.
  • A Gradle dependency is basically the same as using a JAR file, except that Gradle will download the pre-compiled artifact instead of you adding it as a file on your local machine.

Regardless of the above, the dependency contributes its classes to the build and they will be present in the final output (the APK).

Proguard does a few things that can reduce the size of your APK. It can statically analyze all the bytecode and remove classes and methods that are never used. It also can rename classes, fields, and methods to smaller identifiers like "abc", which may shrink the size of the bytecode somewhat.

Yes, the dependencies plus the output of the compilation of the project’s own source code, are sent to dex for bytecode conversion and inclusion in the final APK.

With proguard, the classes that is not being used can be systematically removed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!