當(dāng)應(yīng)用不需要支持幾十種語言時(shí)芳撒,可以通過配置 resConfigs 去除無用的語言資源仑最。
例如下面的代碼就只保留了中文和英文的語言資源:
defaultConfig {
resConfigs "zh","en"
}
注:
resConfigs "hdpi", "xhdpi", "xxhdpi", "xxxhdpi"
在新版本中已經(jīng)廢棄,替代方案是在 gradle 中使用 splits 根據(jù)不同的 ABI 以及不同的屏幕密度分別打包始藕。
android {
splits {
density {
enable true
exclude 'ldpi', 'mdpi'
compatibleScreens 'normal', 'large', 'xlarge'
}
abi {
enable true
reset()
include 'x86', 'x86_64', 'armeabi-v7a', 'arm64-v8a' //select ABIs to build APKs for
universalApk true //generate an additional APK that contains all the ABIs
}
}
}
官方鏈接:https://developer.android.com/studio/build/configure-apk-splits.html