APK contains unused resources

Yes, I saw a similar question asked a few years ago, but it went unanswered, so I just had to take another shot.

I am very annoyed by the fact that the .apk file for a simple Android app I am creating is 4MB in size.

When I parse the .apk, I see that it contains not only unused classes (which can be shared with ProGuard), but all graphical assets from HoloEverywhere.

I mean even the blueprints for themes I don't use at all are in apk.

This behavior looks very counterintuitive, or it just might be that I am doing something very bad.

Finally, my question is: Is there a way to make the .APK contain only the data it needs?

+3


source to share


1 answer


I mean even the blueprints for themes I don't use at all are in apk.

In terms of build tools, they don't have a good way of knowing that you are not using those blueprints.

This behavior looks very illogical.

You can build a tool that can reliably detect unused resources and remove them from the APK. Call it ResGuard or whatever. Even the commercial DexGuard doesn't.



Is there a way to make the .APK contain only the data it needs?

Remove stuff you are not using. You are the only one who knows what it is, and since HoloEverywhere seems to be no longer supported, you don't like updates to worry about.

Long term, I understand there is a blueprint for Gradle for Android to filter out resources as part of the AAR link. I don't know that there is more to come, and you still need to know which resources should be filtered this way. This will prevent you from modifying the original project.

+2


source







All Articles