Enrique
Enrique

Reputation: 10117

Android Studio new project file size too big

I just created a new android project in Android Studio 2.2.3 with just an empty Activity and still it uses 4.11 MB on the device which I think is a lot given that it does contain a single empty Activity. Why is it taking so much space? Is it possible to reduce its size? I have downloaded applications with more functionality and which have more pictures, colors, etc. and are less than 2MB.

Bellow are the steps I used to create the project.

enter image description here

enter image description here

enter image description here

Then, after running the application on a Sony Xperia I get this information.

enter image description here

And when profiling the memory I get.

enter image description here

Which has allocated 3MB and ust 1MB free.

This is the build.gradle file:

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.survey.research.surveycollect"
        minSdkVersion 17
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            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.1.1'
    compile 'com.android.support:design:25.1.1'
    testCompile 'junit:junit:4.12'
}

Upvotes: 2

Views: 2846

Answers (2)

ZeroOne
ZeroOne

Reputation: 9117

Debug apk or release apk? If debug apk its always slightly bigger than release. In release mode, do minifyEnabled = true, shrinkResources = true, zipAlignEnabled = true. It will shrunk your release file size to around 30% (base on my exp) of your debug files.

Upvotes: 1

MaxV
MaxV

Reputation: 2800

Enable minify and resources shrinking in your build.gradle:

buildTypes {
    release {
        minifyEnabled true
        shrinkResources true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

It will remove unused code and resources from your apk

Upvotes: 1

Related Questions