Android的支持库增加APK大小很多 [英] Android support library increases APK size a lot
问题描述
我用在我的Android项目程序兼容性
支持库。 程序兼容性
有很多我不我的应用程序中使用可绘制和资源。这种不必要的文件,增加了我的 900K 应用上面的 2M ,我不喜欢。结果
有什么办法创造APK文件时要排除这些文件?或者我应该混淆在我的code的库,而不是制造依赖?
我使用的摇篮Android Studio中。
I'm using AppCompat
support library in my Android project. AppCompat
has plenty of drawables and resources which I don't use in my app. That unnecessary files increases my 900K app to above 2M, which I don't like.
Is there any way to exclude those files when creating the APK file? Or I should obfuscate the library in my code instead of making a dependency?
I'm using Gradle in Android Studio.
感谢
修改1 我使用ProGuard了。但proguard的不知道,我不希望有绘制-xxxhdpi
或值,它
榜样。
EDIT 1 I am using proguard already. but proguard can't know I don't want to have drawable-xxxhdpi
or values-it
for example.
编辑2 我也是用的Android皮棉,不能帮助我,怎么一回事,因为我不是C直接访问到lib中的$ C $,建设APK文件时,机器人添加它们。
EDIT 2 I am also using Android Lint, which can't help me, beacuse I don't access to lib's code directly, and android adds them when building the APK file.
推荐答案
从Android的摇篮构建系统,因为0.7.0版本:
From Android Gradle Build System, since version 0.7.0:
对产品风味的新选项(和 defaultConfig
)允许资源筛选通过 AAPT
的-c选项
你可以通过单一值( resConfig
)或多个值( resConfigs
)通过DSL。
所有的默认配置值和口味得到结合,并传递给 AAPT
。
请参阅基本的样本。
在基本样本:
New option on product Flavor (and defaultConfig
) allow filtering of resources through the -c option of aapt
You can pass single value (resConfig
) or multiple values (resConfigs
) through the DSL.
All values from the default config and flavors get combined and passed to aapt
.
See "basic" sample.
In the "basic" sample:
defaultConfig {
...
resConfig "en"
resConfigs "nodpi", "hdpi"
}
所以,请尝试以下操作来实现你的要求为:
So, try the following to achieve what you asked for:
productFlavors {
...
frOnly {
resConfig "fr"
}
...
}
请注意,您可能还需要包括 * DPI
,端口
,土地
,等也是如此。
Note that you might also want to include *dpi
, port
, land
, etc.. as well.
答案是:<一href=\"http://stackoverflow.com/questions/20280872/android-studio-exports-strings-from-support-library-to-apk\">Android工作室出口字符串从支持库APK ,感谢 Primoz990
这篇关于Android的支持库增加APK大小很多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!