我的drawables转换为pngs为不同的屏幕导致更大的apk大小,任何减少apk大小或不在构建时转换为png的技巧?
我的build.gradle android块看起来像这样:
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
dexOptions {
javaMaxHeapSize "4g"
maxProcessCount 4
}
defaultConfig {
applicationId "com.toyanathpatro.gurkha"
minSdkVersion 16
targetSdkVersion 25
//noinspection HighAppVersionCode
versionCode 2017063114
versionName "3.3"
multiDexEnabled true
}
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
disable 'RestrictedApi'
}
dataBinding {
enabled true
}
kapt {
generateStubs = true
}
return void
}
答案 0 :(得分:0)
您可以将图片转换为WebP格式。在Android文档中,WebP格式的图像比PNG小26%。您可以查看this以查看如何将图像转换为WebP格式。 您还可以使用Splits和ResConfigs来减少最终的APK大小。
参考文档:
https://developer.android.com/topic/performance/network-xfer.html
https://developer.android.com/topic/performance/reduce-apk-size.html