aar*_*ino 8 android gradle android-gradle-plugin
我决定尝试apk sliptting来减少我的apk的大小.我在gradle构建文件中添加了以下内容
splits {
// Configures multiple APKs based on screen density.
density {
// Configures multiple APKs based on screen density.
enable true
// Specifies a list of screen densities Gradle should not create multiple APKs for.
exclude "ldpi"
// Specifies a list of compatible screen size settings for the manifest.
compatibleScreens 'small', 'normal'
}
}
Run Code Online (Sandbox Code Playgroud)
这成功地为各种密度生成单独的apks.但是,我注意到所有的apks都是相同的大小,没有一个比通用apk小.所以,我将一个(app-hdpi-release.apk)加载到apk分析器中,发现它包含所有资源.没有人被剥夺.
因此,所有配置都有效地生成了具有不同文件名的相同apk.我错过了什么吗?是否有任何其他构建选项可能会阻止正在删除的资源?
小智 0
我做了一些尝试,最后被接受了。在我仅根据屏幕密度进行划分之前。然后我添加了标签 $兼容屏幕$ 并且它起作用了。
\n\n这是最终的分割块 -
\n\nandroid {\n\xc2\xa0 ...\n\xc2\xa0 splits {\n\n\xc2\xa0 \xc2\xa0 density {\n\xc2\xa0 \xc2\xa0 \xc2\xa0 enable true\n\n\xc2\xa0 \xc2\xa0 \xc2\xa0 reset()\n\xc2\xa0 \xc2\xa0 \xc2\xa0 include "mdpi", "hdpi", "xhdpi", "xxhdpi"\n\n\xc2\xa0 \xc2\xa0 \xc2\xa0 // This is the line of code which got it right\n\xc2\xa0 \xc2\xa0 \xc2\xa0 compatibleScreens \'small\', \'normal\', \'large\', \'xlarge\'\n\xc2\xa0 \xc2\xa0 }\n\xc2\xa0 }\n}\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
417 次 |
| 最近记录: |