Android Studio : Size of the release apk of a watch face does not goes under 6Mo

322 Views Asked by At

I found out that every watch face i made did have a release apk file that never goes under 6Mo. Even when it does not contain any drawable. Even the default watch face project is about 6Mo once published & signed.

I assume it is an issue of Android Studio, because some watch face on the store are far lower than 6Mo (ex: Circles Watch Face is about 1.9Mo!!)

I found out that in the intermediate manifest of the mobile package, the following lines are added by the merger:

    <activity
        android:name="android.support.v7.widget.TestActivity"
        android:label="RecyclerViewTestActivity" />

Even with a "tools:node="remove"", it is still added. And with this activity are added a full bunch of ressources (png, values) that I did not use.

Exemple of directories added Content of one ressource directory

Build.gradle of mobile package:

apply plugin: 'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"

defaultConfig {
    applicationId "fr.test"
    minSdkVersion 18
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
wearApp project(':wear')
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.google.android.gms:play-services:7.0.0'
compile "com.google.android.support:wearable:1.1.+"
}

Did someone experienced the same issue and is there a solution to avoid this or reduce the apk size (an option I missed...)?

2

There are 2 best solutions below

2
On BEST ANSWER

There 2 ways to go:

  1. Reduce size using only needed parts of GP services:

    • Google+ com.google.android.gms:play-services-plus:7.5.0
    • Google Account Login com.google.android.gms:play-services-identity:7.5.0
    • Google Actions, Base Client Library com.google.android.gms:play-services-base:7.5.0
    • Google App Indexing
      com.google.android.gms:play-services-appindexing:7.5.0
    • Google App Invites
      com.google.android.gms:play-services-appinvite:7.5.0
    • Google Analytics com.google.android.gms:play-services-analytics:7.5.0
    • Google Cast com.google.android.gms:play-services-cast:7.5.0
    • Google Cloud Messaging com.google.android.gms:play-services-gcm:7.5.0
    • Google Drive com.google.android.gms:play-services-drive:7.5.0
    • Google Fit com.google.android.gms:play-services-fitness:7.5.0
    • Google Location, Activity Recognition, and Places
      com.google.android.gms:play-services-location:7.5.0
    • Google Maps com.google.android.gms:play-services-maps:7.5.0
    • Google Mobile Ads com.google.android.gms:play-services-ads:7.5.0
    • Google Nearby com.google.android.gms:play-services-nearby:7.5.0
    • Google Panorama Viewer
      com.google.android.gms:play-services-panorama:7.5.0
    • Google Play Game services com.google.android.gms:play-services-games:7.5.0
    • SafetyNet com.google.android.gms:play-services-safetynet:7.5.0
    • Google Wallet com.google.android.gms:play-services-wallet:7.5.0
    • Android Wear com.google.android.gms:play-services-wearable:7.5.0
  2. Use proguard - it will cut all unused code

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

It includes google play services for wareable library, which is large itself. You can reduce the size by using ProGuard.