【发布时间】:2023-03-13 12:38:02
【问题描述】:
splits {
// Configures multiple APKs based on screen density.
density {
// Configures multiple APKs based on screen density.
enable true
reset()
// Specifies a list of screen densities Gradle should create multiple APKs for.
include 'ldpi', 'mdpi', 'hdpi', 'xhdpi', 'xxhdpi', 'xxxhdpi'
// Specifies a list of compatible screen size settings for the manifest.
//compatibleScreens 'small', 'normal', 'large', 'xlarge'
}
// Configures multiple APKs based on ABI.
abi {
// Enables building multiple APKs per ABI.
enable false
// By default all ABIs are included, so use reset() and include to specify that we only
// want APKs for x86, armeabi-v7a, and mips.
// Resets the list of ABIs that Gradle should create APKs for to none.
reset()
// Specifies a list of ABIs that Gradle should create APKs for.
include 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
// Specifies that we do want to also generate a universal APK that includes all ABIs.
universalApk true //generate an additional APK that contains all the ABIs
//'armeabi' - Not surported by Realm since v2.0.0
}
}
我正在尝试按 Desity 拆分我的 APK 以减小 APK 大小,使用上面的 Gradle 将 APK 拆分为密度,但每个 APK 的可绘制资源是相同的。
这样的结果应该不会是xhdpi APK只包含drawable-ldrtl-xhdpi-v17、drawable-xhdpi-v4和mipmap-xhdpi-v4?
【问题讨论】:
-
你所有的drawables都是xxxhdpi版本吗?这是没有必要的。查看developer.android.com/guide/practices/… 的第一个提示,这可以显着减小您的 APK 大小。此外,您可以考虑让 ldpi drawables 出来。它们可以从 mdpi 缩小。
-
不,我们只有 xml drawables,我们不能 vectorDrawables.useSupportLibrary = true 因为其他依赖项