简体   繁体   中英

Does including JAR in android project affects the size of apk

I am including a JAR file into my android project and is using some of the classes present in the JAR (not all the JAR).

I want to know, the size of the apk that is generated after building the project is dependent on the JAR I have included or it is dependent only on the classes that I have used in my project.

The entire jar will be included in the APK . You may have used some classes, but they are internally dependent to a large extent. Also, the classes which are not used get included.

An APK is an Android application package file. Each Android application is compiled and packaged in a single file that includes all of the application's code (.dex files), resources, assets, and manifest file. The APK file is basically a .zip file, so there's no way of compressing its size any further.

Memory space on smartphones is often a competitive area, now that most users are storing music, video, messages are more, in addition to downloading apps. The smaller you make your APK, the better it is for the user, and that may be a deciding factor on whether to download your app, versus a similar app that takes up more phone memory.

Tips for reducing file size

There are a number of recommendations for reducing static footprint. You can choose the ones that fit best for your own particular needs. Proguard is the one option.

Check HERE for more details of reducing the apk size.

ProGuard

A tool for code shrinking, like ProGuard , will significantly reduce the static foot print. Note that it is very important to re-test all of the application after applying ProGuard since it may change the application behavior.

As ProGuard replaces the application symbols, to make the code difficult to read, it is important that you retain the symbol mapping, so that you can translate a stack trace back to the original symbols if you have to investigate a crash in your application.

Yes. By default the whole jar goes into the apk. You can use ProGuard to strip all the stuff you don't need during compilation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM