简体   繁体   English

如何在Android Studio中从APK中排除默认资源?

[英]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). 我面临一个小问题,该问题会影响我在Android Studio中构建的APK文件(但即使我从命令提示符处构建它们,同样的问题也会影响我的APK)。

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. 问题是这样的:如果我将.apk重命名为.zip以查看其中的文件,或者即使我使用AS中包含的分析器工具分析.apk,我也会在“ res”目录中看到很多png文件,不包括在内,我什至不使用我的应用程序。 I guess that they're standard icons used in Android, but I would like to exclude them from my built apk file. 我想它们是Android中使用的标准图标,但是我想将它们从我的内置apk文件中排除。

Those file names are like "abc_ic_restofthefilenamehere.png" 这些文件名类似于“ abc_ic_restofthefilenamehere.png”

(example: "abc_ic_star_half_black_16dp.png") (例如:“ 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)? 如果我也从命令提示符进行构建(是否使用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. 但是请注意,有些图像似乎未使用,但实际上是您可能依赖的主题的依赖项(可能是间接的),因此这就是为什么要保留它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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