Currently my app apk size is 22 MB. How will I reduce the app size?
I have compress the size of all the images. I also use the proguard file.
I also use the analyzer apk option in the android studio which shows approx 80% size is due to third party library. I checked through the method count plugin and find that method count is also less.
Than i use the dexcount plugin to check which part of my apk is taking how much method count. Thats the finding:
This is the file of total method count for my apk:
Total method count: 40909
android.support: 22652 com.google.android: 5428
These are the two method count library. Is there way I can reduce the method count. I think reducing the method count will leads to the reducing apk size.
Progaurd File:
#keep json classes
-keepclassmembernames class * extends com.applozic.mobicommons.json.JsonMarker {
!static !transient <fields>;
}
-keepclassmembernames class * extends com.applozic.mobicommons.json.JsonParcelableMarker {
!static !transient <fields>;
}
#GSON Config
-keepattributes Signature
-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.examples.android.model.** { *; }
-keep class org.eclipse.paho.client.mqttv3.logging.JSR47Logger { *; }
-keep class android.support.** { *; }
-keep interface android.support.** { *; }
-dontwarn sun.misc.Unsafe.**
-dontwarn com.google.gson.examples.android.model.**
-dontwarn org.eclipse.paho.client.mqttv3.logging.JSR47Logger.**
-dontwarn android.support.**
-dontwarn com.google.android.gms.**
-dontwarn com.roughike.bottombar.**
-keep class com.sun.pdfview.**{ *; }
-dontwarn com.sun.pdfview.**
-keep class test.**{ *; }
-dontwarn test.**
app gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "user.com.hlthee"
minSdkVersion 17
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
debuggable false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
assets.srcDirs = ['src/main/assets', 'src/main/assets/']
res.srcDirs = ['src/main/res', 'src/main/assets/fonts']
}
}
dexOptions {
jumboMode true
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/ECLIPSE_.SF'
exclude 'META-INF/ECLIPSE_.RSA'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
//for bottom bar
compile 'com.roughike:bottom-bar:2.0.2'
compile 'com.android.support:cardview-v7:25.1.0'
compile 'com.android.support:recyclerview-v7:25.1.0'
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
//for volley
compile 'com.android.volley:volley:1.0.0'
//graph library
compile 'com.github.lecho:hellocharts-android:v1.5.8'
//for file implementation
compile files('libs/commons-io-2.5.jar')
//To show the thumbnail of pdf
compile 'com.github.barteksc:pdfium-android:1.4.0'
//for applozic chat api
compile project(':mobicomkitui')
//for junit
//universal image loader to load the image.
compile 'com.github.bumptech.glide:glide:3.7.0'
//for circlular image
compile 'de.hdodenhof:circleimageview:1.3.0'
//for adherence progress circular bar
compile 'com.github.jakob-grabner:Circle-Progress-View:v1.2.9.1'
//for the sectioned recycler view
compile 'com.github.IntruderShanky:Sectioned-RecyclerView:2.1.1'
//for the multipart things encounter while dealing with image send to server
compile group: 'org.apache.httpcomponents' , name: 'httpclient-android' , version: '4.3.5.1'
compile('org.apache.httpcomponents:httpmime:4.3') {
exclude module: "httpclient"
}
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.getkeepsafe.dexcount'
Use
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
Instead of
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
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