简体   繁体   中英

How to exclude default resources from APK buld in Android Studio?

I'm facing a little "problem" affecting my APK files built in Android Studio (but the same problem affects my APKs even if I build them from command prompt).

The problem is this: if I rename .apk to .zip to see the files inside, or even if I analyze the .apk with the analyzer tool included in AS, I see in the "res" directory a lot of png files that I didn't include and I don't even use in my application. I guess that they're standard icons used in Android, but I would like to exclude them from my built apk file.

Those file names are like "abc_ic_restofthefilenamehere.png"

(example: "abc_ic_star_half_black_16dp.png")

I would like to know if there's a way to exclude those file because I don't use them in my activities (my application is very simple, it doesn't even need icons for notifications or other kinds of similar things).

Is it possible to exclude them? Is there a way to do it if I build from the command prompt too (using gradle)?

Thank you very much! -

Check out the documentation about how to Shrink your resources . This should remove any unused resources in your app.

Note however that some images will seem unused but are actually dependencies (possibly indirect) of a theme you may be depending on, so that's why those would remain.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM