简体   繁体   中英

things that affect the apk file size

what are the ways to reduce the apk file size? and what are the things affecting it? I noticed sometimes when I build the apk, the size goes above 100k and other times it will be around 20k what is the thing it depends on exactly?

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.example.dynamiclist"
        minSdkVersion 16
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled true

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    buildToolsVersion '28.0.3'

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.core:core-ktx:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'com.google.android.material:material:1.1.0'
    implementation 'com.google.firebase:firebase-analytics:17.2.2'
    implementation 'com.google.firebase:firebase-database:19.2.1'

    implementation 'com.karumi:dexter:6.0.2'
    api 'com.otaliastudios:cameraview:2.6.1'

    implementation 'com.google.firebase:firebase-ml-vision:24.0.1'
    implementation 'com.google.firebase:firebase-ml-vision-barcode-model:16.0.2'

    implementation('com.journeyapps:zxing-android-embedded:3.6.0')
    implementation 'com.android.support:multidex:1.0.3'

}

this is the gradele that I have used when it reached 100k if that helps

First you have to Analyse the apk file which gives the information of how much Size allocated to the Resources......

so for analyze apk for Build Apk using:-

Build > Build Bundles(s)/APK(s) > Build APK(s).

After the Build Apk you can analyse your apk using:-

Build > Analyze APK...

this will Gives you the information about the Size are taken by Resources. using which you can Remove unwanted Resources for Decrease Apk size.

I am sure This will Help you for Decrease The Apk Size..

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