Reputation: 3007
Very confused. I just converted a lot of drawables in my res folder to the lossless WebP format. As I did it, Android Studio told me I saved 6mb, however I just build an production-release apk, one for the branch with WebP images and one with everything still as PNG, the difference is negligible. The PNG apk size is 23.2MB, the WebP apk size is 21.3.
I ran the apk analyzer tool, and I can see that the big difference is my res folder is now 7MB smaller, yet that wasn't translated to the apk size?
Here is the apk analyzer results, firstly the old apk (PNGs) Left number is uncompressed, right value is compressed, so what goes out to users in the apk:
Secondly here is the new apk (WebP):
The drawable files are quite clearly smaller, my biggest folder inside res is now 200kb.
Can someone who has played with WebP in Android offer some information on why this didn't work? No other numbers have changed in the apk analyzer.
Edit: Sorry about the small images, view in new tab to see clearer
Upvotes: 2
Views: 1115
Reputation: 3007
Solved why it was happened.
I have shrinkResources
set to true
on my release builds in my build.gradle
, so compression was already taking place.
Makes a lot of sense, mistake on my part, totally forgot about it.
Upvotes: 1
Reputation: 705
You can get better results by using cwebp -near_lossless 40
for your PNG files. I doubt that the automated shrinkResources is able to use near lossless. This may give another 30-40 % compression gain, depending naturally a lot on what kind of graphics you have.
Upvotes: 0