skip to Main Content

I am building a APK from android studio with very simple functions and serveral GUI activities.

The apk is quite large and i found that fonts are taking too much space even I am sure that, I am not using them. Can anyone help on how to remove those fonts dependencies from building APK?

After carefully looking at the APK analysis, we found that fontsUsedinSDK.txt contains all the fonts i have never imported or used.

I did not have any idea to solve this i was hoping someone could give a hand.


Apk analysis information :

Dependencies from build.gradle:

implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.9.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

2

Answers


  1. You have probably specified a text style somewhere (in xml or programmatically) that caused to include these, you seem to have fonts for about 8 languages included.

    You could carefully specify a font in any part that uses text, so that you only include the fonts needed for one targeted language. There are single language versions available of the NotoSans Font

    See answer on specifying your own fonts.

    You could also use the Downloadable Font feature of Android possibly to reduce your App Size.

    Login or Signup to reply.
  2. In your build.dradle enable code shrinking

    buildTypes {
     release {
      isMinifyEnabled = true
      isShrinkResources = true
      proguardFiles(
         getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
     }
    }
    

    And set the proguard rules also

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search