I have the following dependency:
implementation 'com.google.android.material:material:1.5.0-alpha02'
from this repository. However it turns out I only need the CircularProgressIndicator
from it, now I don’t want the entire dependency shipped with my app (I need only what I need from it). How can I accomplish this? I am thinking along the lines of:
implementation 'com.google.android.material:material:1.5.0-alpha02:AddOnlyCircularProgressIndicatorRelatedComponents'
2
Answers
Your options are:
Fork the library, copying only the pieces that make up
CircularProgressIndicator
. Note that there may be dozens or hundreds of such pieces: Java classes, resources, etc.Include the library, and rely on R8/ProGuard to remove unused code from the library, as it does for everything else in your app
If your concern is app size, you need not worry, implement the full dependency and allow ProGuard do the magic.
Under the hood, Proguard removes all unused code from your compiled project thereby, and reduces your app size significantly. To learn how to integrate Proguard into your application, check this out.
PS: Other benefits of using Proguard include: