Reputation: 18376
In all my previous projects debug build always bigger & release build smaller.
But strange issue occur for me. When I build the debug APK it have 1085KB
If I build the release APK it have 2432KB
Any one give me solution for this issue.
My dependencies in build.gradle :
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "ranjih.kotlinandroid"
minSdkVersion 14
targetSdkVersion 25
versionCode 5
versionName "1.3"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.firebase:firebase-config:10.2.1'
compile 'com.google.firebase:firebase-messaging:10.2.1'
compile 'com.google.android.gms:play-services-ads:10.2.1'
compile 'com.android.support:support-v4:25.3.1'
compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
transitive = true;
}
testCompile 'junit:junit:4.12'
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile project(path: ':lib')
}
apply plugin: 'com.google.gms.google-services'
repositories {
maven {
url "https://jitpack.io"
}
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
// These docs use an open ended version so that our plugin
// can be updated quickly in response to Android tooling updates
// We recommend changing it to the latest version from our changelog:
// https://docs.fabric.io/android/changelog.html#fabric-gradle-plugin
classpath 'io.fabric.tools:gradle:1.+'
}
}
Upvotes: 4
Views: 2624
Reputation: 345
If you're just getting the debug apk generated by Android Studio when you try to Run or Debug the app in a device/emulator, it seems that this apk only packages the resources/dependencies for that specific device specs.
Try going with Build > Build APK, you will probably notice that the (supposedly) same debug apk will be bigger, and probably even so than the release one.
I've also answered a similar question with more details on why this happens.
Upvotes: 1
Reputation: 4252
In case of a large png files existed try to use next:
android {
…
buildTypes {
release {
crunchPngs true // or false
}
}
}
Upvotes: 0
Reputation: 7918
You're testing without for debug builds and with for release builds, that's simply a no-go.
Test with the same build variant.
I've always had the same or lower APK size when enabling minify and shrinkResources.
Libraries can define different resources depending on build type, so one of them might need take up more space when built for release than it does for debug.
Otherwise try and decompile the APK's using Android Studio's built-in tool and see what is taking up all that space.
Upvotes: 3