Export signed app without “optimizing” png images

后端 未结 5 804
北海茫月
北海茫月 2021-01-12 04:40

When I export an apk from eclipse, it compresses all of the png images. For example, one 4.6 KB png became 2.15 KB inside the apk. However I prefer to optimize png files usi

5条回答
  •  北恋
    北恋 (楼主)
    2021-01-12 05:43

    Google recently introduced a new PNG processor in aapt 0.9.1 in the Android SDK Build Tools that fixes this issue of increased PNG sizes after aapt optimization.

    With this update, it is now possible for Android Studio and Gradle to switch between the PNG processors with the following change in your build.gradle configuration file:

    android {
        ...
        aaptOptions.useAaptPngCruncher = false
    }
    

    By adding this line, aapt uses the new PNG processor in which it checks to see if the "optimized" PNG files are smaller than the original PNG files. I was able to reduce 4.8 MB in my compiled APK and have not encountered any bugs/issues with the new build configuration.

提交回复
热议问题