SlideShare a Scribd company logo
Save users' data!
APP SIZE
Mateusz
Grzechociński
Jacek
Karaśkiewicz
SAVE USERS’ DATA !
Tips for reducing the APK size.
Mateusz
Grzechociński
Jacek
Karaśkiewicz
Save users' data!
Save users' data!
Save users' data!
2Years
1mlnUsers in Dec 2016
14minSDK
200Layouts
62MBAPK size in mid 2016
ANALYZE CURRENT STATE
APK ANALYZER
MID 2016
APK ANALYZER
MID 2016
RAW VS DOWNLOAD
• Focus on both
RAW VS DOWNLOAD
• Focus on both
• Install size
RAW VS DOWNLOAD
• Focus on both
• Install size
• Update size
RAW VS DOWNLOAD
• Focus on both
• Install size
• Update size
APK PATCH SIZE ESTIMATORhttps://github.com/googlesamples/apk-patch-size-estimator
APK PATCH SIZE ESTIMATORhttps://github.com/googlesamples/apk-patch-size-estimator
$ python apk_patch_size_estimator.py --old-file ~/Downloads/IKO3_android_rc_v3.106.114_b8907.apk
--new-file ~/Downloads/IKO3_android_rc_v3.106.122_b9513.apk
New APK size on disk: 29999643 bytes [28.6MB]
Estimated download size for new installs:
Full new APK (gzipped) size: 26227473 bytes [25MB]
Estimated download size for updates from the old APK, using Bsdiff:
Bsdiff patch (gzipped) size: 6858901 bytes [6.54MB]
Estimated download size for updates from the old APK,
using File-by-File:
File-by-File patch (gzipped) size: 3167479 bytes [3.02MB]
APK ANALYZER
MID 2016
AAPT
android {
…
aaptOptions {
cruncherEnabled = true
}
}
AAPT
• No colors?
AAPT
• No colors?
• No alpha?
AAPT
• No colors?
• No alpha?
Standard PS Export
720x510 RGBA
Save users' data!
Save users' data!
AAPT
AAPT
AAPT
48%
reduction
„for free”
AAPT
• No colors?
• No alpha?
• 256 colors?
AAPT
• No colors?
• No alpha?
• 256 colors?
Standard PS Export
1440x1268 RGBA
2192 colors
Save users' data!
Save users' data!
AAPT
AAPT
AAPT
0%
reduction
„for free”
AAPT
53MBres/ in GIT
vs
AAPT EFFICIENCY
MID 2016
53MBres/ in GIT
vs
AAPT EFFICIENCY
MID 2016
res/ in APK
53MBres/ in GIT
vs
50,3MB
AAPT EFFICIENCY
MID 2016
res/ in APK
53MBres/ in GIT
vs
50,3MB
5%
reduction
„for free”
AAPT EFFICIENCY
MID 2016
res/ in APK
WHAT IF 256?
1440x1268 RGBA PNG
2192 colors
1440x1268 RGBA PNG
251 colors
vs
WHAT IF 256?
1440x1268 RGBA PNG
2192 colors
1440x1268 RGBA PNG
251 colors
vs
123KB
WHAT IF 256?
1440x1268 RGBA PNG
2192 colors
1440x1268 RGBA PNG
251 colors
vs
123KB 57KB
Do
It
Yourself
GRAPHICS
ANDROID IMAGE FORMATS
• *.png
ANDROID IMAGE FORMATS
• *.png
• *.jpg
ANDROID IMAGE FORMATS
• *.png
• *.jpg
• *.webp
ANDROID IMAGE FORMATS
• *.png
• *.jpg
• *.webp
• *.bmp
ANDROID IMAGE FORMATS
• *.png
• *.jpg
• *.webp
• *.bmp
ANDROID IMAGE FORMATS
• *.gif
• *.png
• *.jpg
• *.webp
ANDROID IMAGE FORMATS
Portable
Network
Graphics
PNGQUANT
Lossy PNG compressor
PNGQUANT
Lossy PNG compressor
+
ZOPFLI
Very good, but slow, deflate or zlib compression.
INPUT
1200x869 RGBA
64249 colors
566KB
ZOPFLI
INPUT
1200x869 RGBA
64249 colors
566KB
1200x869 RGBA
64249 colors
459KB (-19%)
1200x869 RGBA
64249 colors
459KB (-19%)
PNGQUANT
1200x869 Palette
256 colors
126KB (-78%)
INPUT
1200x869 RGBA
64249 colors
566KB
ZOPFLI
ZOPFLI + PNGQUANT
1200x869 Palette
256 colors
117KB (-80%)
1200x869 RGBA
64249 colors
459KB (-19%)
INPUT
1200x869 RGBA
64249 colors
566KB
PNGQUANT
1200x869 Palette
256 colors
126KB (-78%)
ZOPFLI
ZOPFLI +
PNGQUANT
INPUT
PNGQUANT
ZOPFLI
ZOPFLI +
PNGQUANT
PNGQUANT
ZOPFLIINPUT
will be
Joint
Photographic
Experts
Group
CONVERT
Convert between image formats as well as resize an image, blur, crop, despeckle, dither, draw on,
flip, join, re-sample, and much more
GUETZLI
Perceptual JPEG encoder
GUETZLI
Perceptual JPEG encoder
+
BUTTERAUGLI
Estimates the psychovisual difference between two images
1200x869 RGBA PNG
64249 colors
566KB
guetzli binary search
w/ BA 2.0
1200x869 RGBA PNG
64249 colors
566KB
guetzli binary search
w/ BA 2.0
1200x869 RGB JPEG
quality 90
105KB
1200x869 RGBA PNG
64249 colors
566KB
vs
1200x869 Palette
256 colors
117KB
1200x869 RGB JPEG
quality 90
105KB
WEBP
WEBP
API 14+
• Lossy & non-transparent
• better than JPEG
WEBP
API 18+
• Lossless & transparent
• better than PNG
API 14+
• Lossy & non-transparent
• better than JPEG
WEBP
API 18+
• Lossless & transparent
• better than PNG
API 14+
• Lossy & non-transparent
• better than JPEG
1200x869 RGBA PNG
64249 colors
566KB
1200x869 RGBA PNG
64249 colors
566KB
WebP Lossy
1200x869 RGB WebP
quality 80%
61KB
1200x869 RGBA PNG
64249 colors
566KB
WebP Lossy
vs
1200x869 RGB JPEG by Guetzli
quality 90
105KB
1200x869 RGB WebP
quality 80%
61KB
APK RAW SIZE #1
62MB vs
MID 2016
APK RAW SIZE #1
62MB vs
MID 2016 + Graphics optimizations
APK RAW SIZE #1
62MB vs
31MBMID 2016 + Graphics optimizations
50%
reduction
APK RAW SIZE #1
62MB vs
31MBMID 2016 + Graphics optimizations
DENSITIES
XXXHDPI
XXHDPI
XHDPI
HDPI
MDPI
DENSITIES
XXXHDPI
XXHDPI
XHDPI
HDPI
DENSITIES
XXXHDPI
XXHDPI
XHDPI
HDPI
AUTOSCALING
hdpi
AUTOSCALING
hdpi
AUTOSCALING
hdpi
xxxhdpi
downsized to hdpi
vs
AUTOSCALING
hdpi
AUTOSCALING
hdpi
AUTOSCALING
vs
hdpi xxxhdpi
downsized to hdpi
31MB vs
APK RAW SIZE #2
Graphics optimizations
31MB vs
APK RAW SIZE #2
+ Removed all mdpi
+ Removed all but xxxhdpi for large gfx
Graphics optimizations
31MB vs
22MB
APK RAW SIZE #2
+ Removed all mdpi
+ Removed all but xxxhdpi for large gfx
Graphics optimizations
31MB vs
22MB
29%
reduction
APK RAW SIZE #2
+ Removed all mdpi
+ Removed all but xxxhdpi for large gfx
Graphics optimizations
ICONS
VECTORDRAWABLE
VECTORDRAWABLE
• Native support 21+
VECTORDRAWABLE
• Native support 21+
• „gradle" way
VECTORDRAWABLE
• Native support 21+
• „gradle" way
• „support” way
VECTORDRAWABLECOMPAT
android {
…
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}
MIGRATING
<vector android:height="50dp"
android:viewportHeight="48.0"
android:viewportWidth="48.0"
android:width="50dp"
xmlns:android=„[…]”>
<path
android:fillAlpha="1"
android:fillColor="@color/iko_blue"
android:pathData=„M40.09,[…]”
android:strokeColor="#00000000"/>
</vector>
iko_ic_topup.png iko_ic_topup.xml
MIGRATING
<vector android:height="50dp"
android:viewportHeight="48.0"
android:viewportWidth="48.0"
android:width="50dp"
xmlns:android=„[…]”>
<path
android:fillAlpha="1"
android:fillColor="@color/iko_blue"
android:pathData=„M40.09,[…]”
android:strokeColor="#00000000"/>
</vector>
SVG
AS
Import
MIGRATING
<vector android:height="50dp"
android:viewportHeight="48.0"
android:viewportWidth="48.0"
android:width="50dp"
xmlns:android=„[…]”>
<path
android:fillAlpha="1"
android:fillColor="@color/iko_blue"
android:pathData=„M40.09,[…]”
android:strokeColor="#00000000"/>
</vector>
SVG
inloop
svg2android
MIGRATING
SVG
POTRACE
Transforming bitmaps into vector graphics
BMP
$ potrace -s iko_ic_topup.bmp
BMP SVG
vs
vs
Animated
Vector
Drawable
Animated
Vector
Drawable
ISSUES
<layer-list /> drawable on Lollipop
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/iko_white"/>
<padding android:top="7dp"
android:bottom="7dp"
android:left="7dp"
android:right="7dp"/>
</shape>
</item>
<item android:drawable=„@drawable/ic_logo_visa"/>
</layer-list>
ISSUES
<layer-list /> drawable on Lollipop
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/iko_white"/>
<padding android:top="7dp"
android:bottom="7dp"
android:left="7dp"
android:right="7dp"/>
</shape>
</item>
<item android:drawable=„@drawable/ic_logo_visa"/>
</layer-list>
REUSING GRAPHICS
REUSING GRAPHICS
Tint
REUSING GRAPHICS
Tint
REUSING GRAPHICS
Tint
REUSING GRAPHICS
Tint
REUSING GRAPHICS
Tint
REUSING GRAPHICS
Tint Rotate
REUSING GRAPHICS
Tint Rotate
22MB vs
APK RAW SIZE #3
Graphics optimizations
Removed all mdpi
Removed all but xxxhdpi for large gfx
22MB vs
APK RAW SIZE #3
+ Switched toVD
+ Reusing icons
Graphics optimizations
Removed all mdpi
Removed all but xxxhdpi for large gfx
22MB vs
20MB
APK RAW SIZE #3
+ Switched toVD
+ Reusing icons
Graphics optimizations
Removed all mdpi
Removed all but xxxhdpi for large gfx
22MB vs
20MB
9%
reduction
APK RAW SIZE #3
+ Switched toVD
+ Reusing icons
Graphics optimizations
Removed all mdpi
Removed all but xxxhdpi for large gfx
~900 PNG icons
~310 PNG icons ~160VD files
WHAT’S UNUSED?
PROGUARD EVERYTHING?
LINT
RESOURCE SHRINKING
RESOURCE SHRINKING
android {
…
buildTypes {
release {
minifyEnabled true
shrinkResources true
}
}
}
RESOURCE SHRINKING
RESOURCE SHRINKING
RESOURCE SHRINKING
RESOURCE SHRINKING
RESOURCE SHRINKING
„if your code makes a call to Resources.getIdentifier(), code is
looking up resource names based on dynamically-generated
strings.
[…] resource shrinker behaves defensively by default and marks all
resources with a matching name format as potentially used and
unavailable for removal.”
https://developer.android.com/studio/build/shrink-code.html
RESOURCE SHRINKING
20MB vs
APK RAW SIZE #4
Graphics optimizations
Removed all mdpi
Removed all but xxxhdpi for large gfx

Switched toVD
Reusing icons
20MB vs
APK RAW SIZE #4
+ Shrinked resourcesGraphics optimizations
Removed all mdpi
Removed all but xxxhdpi for large gfx

Switched toVD
Reusing icons
20MB vs
19MB
APK RAW SIZE #4
+ Shrinked resourcesGraphics optimizations
Removed all mdpi
Removed all but xxxhdpi for large gfx

Switched toVD
Reusing icons
20MB vs
19MB
5%
reduction
APK RAW SIZE #4
+ Shrinked resourcesGraphics optimizations
Removed all mdpi
Removed all but xxxhdpi for large gfx

Switched toVD
Reusing icons
RESOURCES.ARSC
RESOURCES.ARSC
RESOURCES.ARSC
RESOURCES.ARSC
RESOURCES.ARSC
RESOURCES.ARSC
RESOURCES.ARSC
android {
…
defaultConfig {
resConfigs „pl”, „en”
}
}
19MB vs
APK RAW SIZE #5
Graphics optimizations
Removed all mdpi
Removed all but xxxhdpi for large gfx

Switched toVD
Reusing icons
Shrinked resources
19MB vs
APK RAW SIZE #5
+ Fixed list of configurations
Graphics optimizations
Removed all mdpi
Removed all but xxxhdpi for large gfx

Switched toVD
Reusing icons
Shrinked resources
19MB vs
17MB
APK RAW SIZE #5
+ Fixed list of configurations
Graphics optimizations
Removed all mdpi
Removed all but xxxhdpi for large gfx

Switched toVD
Reusing icons
Shrinked resources
19MB vs
17MB
10%
reduction
APK RAW SIZE #5
+ Fixed list of configurations
Graphics optimizations
Removed all mdpi
Removed all but xxxhdpi for large gfx

Switched toVD
Reusing icons
Shrinked resources
TODAY
vs
mid 2016 vs today
APK RAW SIZE
vs
73%
reduction
mid 2016 vs today
APK RAW SIZE
APK SPLIT
XXXHDPI XXHDPI
XHDPI HDPI
APK
APK SPLIT
XXXHDPI XXHDPI XHDPI HDPI
APK APK APKAPK
PROTIPS
PROTIPS
• Optimize your graphics
PROTIPS
• Optimize your graphics
• Use any tool you choose
PROTIPS
• Optimize your graphics
• Use any tool you choose
• Experiment with PNG/JPEG/WebP
PROTIPS
• Optimize your graphics
• Use any tool you choose
• Experiment with PNG/JPEG/WebP
• Switch doVD
PROTIPS
• Optimize your graphics
• Use any tool you choose
• Experiment with PNG/JPEG/WebP
• Switch doVD
•Start playing with APK Analyzer
SEE ALSO
SEE ALSO
• Colt McAnlis (Google)
• #perfMatters videos onYouTube
• „Image compression for Android dev” video from Google I/O 2016
• Articles on Medium
SEE ALSO
• Colt McAnlis (Google)
• #perfMatters videos onYouTube
• „Image compression for Android dev” video from Google I/O 2016
• Articles on Medium
• Wojtek Kaliciński (Google)
• „Put your app on diet” video from Google I/O 2016
• #SmallerAPK articles on Medium
Mateusz
Grzechociński
Jacek
Karaśkiewicz
THANKYOU!
@j_karaskiewicz@mgrzechocinski
Mateusz
Grzechociński
Jacek
Karaśkiewicz
THANKYOU!
@j_karaskiewicz@mgrzechocinski

More Related Content

PDF
[db tech showcase Tokyo 2018] #dbts2018 #C32 『Deep Dive on the Amazon Aurora ...
PDF
AWS re:Invent 2017 주요 신규 서비스 분야별 요약 - 윤석찬 (AWS테크에반젤리스트)
PDF
Generating efficient APK by Reducing Size and Improving Performance
PDF
[2018 GDC] Real-Time Ray-Tracing Techniques for Integration into Existing Ren...
PDF
Python time series analysis and visualization for self-driving cars
PDF
Optimize APK size
PDF
The latest in site speed: advanced #webperf 2018
PDF
Unblocking The Main Thread - Solving ANRs and Frozen Frames
[db tech showcase Tokyo 2018] #dbts2018 #C32 『Deep Dive on the Amazon Aurora ...
AWS re:Invent 2017 주요 신규 서비스 분야별 요약 - 윤석찬 (AWS테크에반젤리스트)
Generating efficient APK by Reducing Size and Improving Performance
[2018 GDC] Real-Time Ray-Tracing Techniques for Integration into Existing Ren...
Python time series analysis and visualization for self-driving cars
Optimize APK size
The latest in site speed: advanced #webperf 2018
Unblocking The Main Thread - Solving ANRs and Frozen Frames

Similar to Save users' data! (20)

PDF
Unblocking The Main Thread_ Solving ANRs and Frozen Frames.pdf
PDF
Don't turn on/off your Photoshop yet
PPTX
MongoDB and DigitalOcean Automation with Cloud Manager
PDF
Automatic image moderation in classifieds, Jarosław Szymczak
PDF
Automatic image moderation in classifieds
PPTX
The Physics of Fast Image Compression
PPTX
Physics of Fast Graphics
PPTX
From Docker to Production - SunshinePHP 2017
PDF
The Road To Single Dex (GDG San Francisco Meetup)
PDF
SearchLeeds 2018 - Bastian Grimm - Peak Ace - International site speed: Going...
PDF
Super speed around the globe - SearchLeeds 2018
PDF
The Road To Single Dex (Gradle Summit 2017)
PPTX
Writing plugins for Nagios and Opsview - CAPSiDE Tech Talks
PDF
Getting started with High-Definition Render Pipeline for games- Unite Copenha...
PDF
stackconf 2023 | Dynamic Image Optimization with imgproxy at Schwarz IT by An...
PDF
Android Reverse Engineering
PDF
Web optimizations Back to the basics - Razvan Rosu
PDF
Adobe dng 3.0 converter read me
PDF
Be a better developer with Docker (revision 3)
Unblocking The Main Thread_ Solving ANRs and Frozen Frames.pdf
Don't turn on/off your Photoshop yet
MongoDB and DigitalOcean Automation with Cloud Manager
Automatic image moderation in classifieds, Jarosław Szymczak
Automatic image moderation in classifieds
The Physics of Fast Image Compression
Physics of Fast Graphics
From Docker to Production - SunshinePHP 2017
The Road To Single Dex (GDG San Francisco Meetup)
SearchLeeds 2018 - Bastian Grimm - Peak Ace - International site speed: Going...
Super speed around the globe - SearchLeeds 2018
The Road To Single Dex (Gradle Summit 2017)
Writing plugins for Nagios and Opsview - CAPSiDE Tech Talks
Getting started with High-Definition Render Pipeline for games- Unite Copenha...
stackconf 2023 | Dynamic Image Optimization with imgproxy at Schwarz IT by An...
Android Reverse Engineering
Web optimizations Back to the basics - Razvan Rosu
Adobe dng 3.0 converter read me
Be a better developer with Docker (revision 3)
Ad

More from Mateusz Grzechociński (7)

PDF
Deep dive into Android async operations
PDF
Meet Jack & Jill
PDF
Gitkata push and_pull_options
PDF
Gitkata refspec
PDF
Gitkata fish shell
PDF
Gitkata undoing changes
PDF
Gitkata rerere
Deep dive into Android async operations
Meet Jack & Jill
Gitkata push and_pull_options
Gitkata refspec
Gitkata fish shell
Gitkata undoing changes
Gitkata rerere
Ad

Recently uploaded (20)

PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
Introduction to Artificial Intelligence
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
System and Network Administraation Chapter 3
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
L1 - Introduction to python Backend.pptx
PDF
Nekopoi APK 2025 free lastest update
PPTX
ai tools demonstartion for schools and inter college
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Odoo Companies in India – Driving Business Transformation.pdf
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Introduction to Artificial Intelligence
Softaken Excel to vCard Converter Software.pdf
System and Network Administraation Chapter 3
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Upgrade and Innovation Strategies for SAP ERP Customers
How to Choose the Right IT Partner for Your Business in Malaysia
Adobe Illustrator 28.6 Crack My Vision of Vector Design
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PTS Company Brochure 2025 (1).pdf.......
Wondershare Filmora 15 Crack With Activation Key [2025
L1 - Introduction to python Backend.pptx
Nekopoi APK 2025 free lastest update
ai tools demonstartion for schools and inter college
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool

Save users' data!