I have multiple libraries in my project like
dependencies {
compile files('libs/universalloaderlibrary.jar')
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:design:22.2.1'
compile 'com.android.support:recyclerview-v7:22.2.1'
compile 'com.android.support:cardview-v7:22.2.1'
compile 'de.hdodenhof:circleimageview:1.3.0'
compile 'com.jakewharton:butterknife:7.0.1'
//noinspection GradleCompatible
compile 'com.google.android.gms:play-services-gcm:7.3.0'
compile 'com.github.castorflex.smoothprogressbar:library:1.1.0'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.loopj.android:android-async-http:1.4.8'
compile 'com.android.support:multidex:1.0.1'
}
and other libraries. Do they increase app size too much. I have more than 25 libraries in my project. Right now APK size is 11 MB and i have to add more functionalities in that. What could be the reason?
I have some questions, regarding this.
What takes more memory ?
compile 'com.android.support:appcompat-v7:22.2.1'
.I have read that by Enabling Proguard
, setting minifyEnabled
true can reduce app size.
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
How do they work behind the picture ?
Should we avoid to use multiple libraries in project ?
Lots of questions are in my mind for reducing APK size. Any kind of suggestion and help would be appreciable. Thanks in Advance.
All three of those methods will increase the size of your APK. The difference between them is where does the source code reside:
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With