Download - Beating Android Fragmentation
![Page 1: Beating Android Fragmentation](https://reader034.vdocuments.site/reader034/viewer/2022052315/554fa033b4c9057b298b486b/html5/thumbnails/1.jpg)
Beating Android FragmentationJuan Gomez
![Page 2: Beating Android Fragmentation](https://reader034.vdocuments.site/reader034/viewer/2022052315/554fa033b4c9057b298b486b/html5/thumbnails/2.jpg)
Agenda
• Intro
• Types of fragmentation
• Tools
• Best practices
• Review
• Q&A
!2
![Page 3: Beating Android Fragmentation](https://reader034.vdocuments.site/reader034/viewer/2022052315/554fa033b4c9057b298b486b/html5/thumbnails/3.jpg)
Intro
Who am I?
• Mobile Engineer at Eventbrite
• Previously at OneLouder Apps
• Android & Python Developer
!3
![Page 4: Beating Android Fragmentation](https://reader034.vdocuments.site/reader034/viewer/2022052315/554fa033b4c9057b298b486b/html5/thumbnails/4.jpg)
Over 2 million events150 million tickets sold
$2 billion in gross ticket salesEvents in 179 countries
Eventbrite by the Numbers
![Page 6: Beating Android Fragmentation](https://reader034.vdocuments.site/reader034/viewer/2022052315/554fa033b4c9057b298b486b/html5/thumbnails/6.jpg)
ANDROID FRAGMENTATION
![Page 7: Beating Android Fragmentation](https://reader034.vdocuments.site/reader034/viewer/2022052315/554fa033b4c9057b298b486b/html5/thumbnails/7.jpg)
Is it really that bad?
!
!
!
!
!
!
Android Fragmentation Visualized (http://bit.ly/1fvOXF0)!7
![Page 8: Beating Android Fragmentation](https://reader034.vdocuments.site/reader034/viewer/2022052315/554fa033b4c9057b298b486b/html5/thumbnails/8.jpg)
Types of fragmentation
• OS Fragmentation
• OEM Fragmentation
• Hardware Fragmentation
!8
![Page 9: Beating Android Fragmentation](https://reader034.vdocuments.site/reader034/viewer/2022052315/554fa033b4c9057b298b486b/html5/thumbnails/9.jpg)
OS Fragmentation
Mainly refers to the different versions of Android being used at the same time
!9
![Page 10: Beating Android Fragmentation](https://reader034.vdocuments.site/reader034/viewer/2022052315/554fa033b4c9057b298b486b/html5/thumbnails/10.jpg)
OS Fragmentation
• Android Forks
• Other OSes with Android app support
!10
![Page 11: Beating Android Fragmentation](https://reader034.vdocuments.site/reader034/viewer/2022052315/554fa033b4c9057b298b486b/html5/thumbnails/11.jpg)
OEM fragmentation
• Skins
• TouchWiz (Samsung)
• Sense (HTC)
• MotoBlur (Motorola)
• OEM OS modifications.
• Changes to AOSP even on certain API calls.
!11
![Page 12: Beating Android Fragmentation](https://reader034.vdocuments.site/reader034/viewer/2022052315/554fa033b4c9057b298b486b/html5/thumbnails/12.jpg)
HW Fragmentation
• All the different types of Hardware features (keyboard, camera, screen, HW buttons, etc).
!12
![Page 13: Beating Android Fragmentation](https://reader034.vdocuments.site/reader034/viewer/2022052315/554fa033b4c9057b298b486b/html5/thumbnails/13.jpg)
HW Fragmentation
• Android is designed to manage HW fragmentation
• The pain points in this area are on low level things like different chipsets, GPUs, CPU cores, etc.
• Android x86 is the extreme example of this.
!13
![Page 14: Beating Android Fragmentation](https://reader034.vdocuments.site/reader034/viewer/2022052315/554fa033b4c9057b298b486b/html5/thumbnails/14.jpg)
TOOLS
![Page 15: Beating Android Fragmentation](https://reader034.vdocuments.site/reader034/viewer/2022052315/554fa033b4c9057b298b486b/html5/thumbnails/15.jpg)
The Basics
• Set minSdkVersion to the lowest API Level you want to support.
• Set targetSdkVersion to the current highest API Level.
• Use Android Lint to find code that is not supported by your minimum API Level (and other possible problems).
• Use fragments when possible.
!15
![Page 16: Beating Android Fragmentation](https://reader034.vdocuments.site/reader034/viewer/2022052315/554fa033b4c9057b298b486b/html5/thumbnails/16.jpg)
The Basics
• Encapsulate your version checking logic
• Don’t fill your code with this:
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.#####)
• Use the Support Libraries
• Follow the Android Design Guidelines
• http://bit.ly/1hMUNmX
• Beware of Google Play Services!
!16
![Page 17: Beating Android Fragmentation](https://reader034.vdocuments.site/reader034/viewer/2022052315/554fa033b4c9057b298b486b/html5/thumbnails/17.jpg)
Support Libraries
• Support Library v4 • Fragments • Rich Notifications, View Pager, Navigation Drawer,
Accessibility, Loaders. • Support Library v7
• ActionBarCompat • Grid Layout, Media Router
• Support Library v8 • Renderscript for API Level < 14
!17
![Page 18: Beating Android Fragmentation](https://reader034.vdocuments.site/reader034/viewer/2022052315/554fa033b4c9057b298b486b/html5/thumbnails/18.jpg)
3rd-party libraries• ActionBarSherlock
• NineOldAndroids
• Android Asset Studio
• http://bit.ly/Lo6Xb5
• Square libraries:
• OkHttp, Picasso, Wire, Retrofit
• CommonsWare libraries
• http://bit.ly/1d7NQs0!18
![Page 19: Beating Android Fragmentation](https://reader034.vdocuments.site/reader034/viewer/2022052315/554fa033b4c9057b298b486b/html5/thumbnails/19.jpg)
HTTP Stack
• Avoid using Apache HTTPClient
• Only use if you’re still supporting API Level < 10
• You should be using URLConnection and its descendants.
• Better yet use OkHttp from Square (fork of HttpURLConnection).
• You could also use Volley from Google
!19
![Page 20: Beating Android Fragmentation](https://reader034.vdocuments.site/reader034/viewer/2022052315/554fa033b4c9057b298b486b/html5/thumbnails/20.jpg)
Migrate to Gradle
• Gradle is a powerful tool that can help manage complicated compatibility scenarios.
• Use “flavors” and “buildTypes” to create different APKs for different OSes, chipsets, etc (Kindle, Nook, Tegra, x86, Blackberry, even 2.x and 4.x versions).
!20
![Page 21: Beating Android Fragmentation](https://reader034.vdocuments.site/reader034/viewer/2022052315/554fa033b4c9057b298b486b/html5/thumbnails/21.jpg)
BEST PRACTICES
![Page 22: Beating Android Fragmentation](https://reader034.vdocuments.site/reader034/viewer/2022052315/554fa033b4c9057b298b486b/html5/thumbnails/22.jpg)
API Levels Recommendations
• Older projects should be supporting API Level ≥ 8
• Recommended would be API Level ≥ 10
• If you’re already using ActionBarSherlock, no need to migrate to ActionBarCompat.
• New projects should start with minSdkVersion=”14”
• If you absolutely have to support API Level ≥ 8 then use ActionBarCompat.
!22
![Page 23: Beating Android Fragmentation](https://reader034.vdocuments.site/reader034/viewer/2022052315/554fa033b4c9057b298b486b/html5/thumbnails/23.jpg)
minSdkVersion=”14”
• This is a new “movement” within the Android community that advocates dropping support for older versions of Android (mainly 2.x) !
• Started by Jeff Gilfelt at Google I/O last year
• Advocated by Reto Meier from Google during I/O and other events.
!23
![Page 24: Beating Android Fragmentation](https://reader034.vdocuments.site/reader034/viewer/2022052315/554fa033b4c9057b298b486b/html5/thumbnails/24.jpg)
Lots of Testing
• Hopefully automated!
• Test on actual devices
• Use tools like JUnit, Espresso, Monkey, Roboelectric, Robotium, etc.
• Leverage something like Spoon (from Square) to run your tests on multiple devices.
!24
![Page 25: Beating Android Fragmentation](https://reader034.vdocuments.site/reader034/viewer/2022052315/554fa033b4c9057b298b486b/html5/thumbnails/25.jpg)
Leverage analytics
• Measure everything
• Make decisions based on your data
• Analytics suites:
• Flurry
• MixPanel
!25
![Page 26: Beating Android Fragmentation](https://reader034.vdocuments.site/reader034/viewer/2022052315/554fa033b4c9057b298b486b/html5/thumbnails/26.jpg)
Crash reporting
• Get a tool to monitor crashes
• Lots of options, including:
• Crashlytics (Free)
• Crittercism
• HockeyApp
• Some analytics suites provide this as well (like Flurry)
• Worst case, use Google Play Dev Console
!26
![Page 27: Beating Android Fragmentation](https://reader034.vdocuments.site/reader034/viewer/2022052315/554fa033b4c9057b298b486b/html5/thumbnails/27.jpg)
Tools from Google
• Multiple APK support.
• Alpha and Beta groups
• Combined with Analytics + Crash reporting
• Beta users can’t post reviews
• Staged rollouts.
!27
![Page 28: Beating Android Fragmentation](https://reader034.vdocuments.site/reader034/viewer/2022052315/554fa033b4c9057b298b486b/html5/thumbnails/28.jpg)
Summary• Android fragmentation is massively over hyped! • Be aware of the different types of fragmentation • Use libraries to homogenize feature support. • Start planning on dropping 2.x support (Old projects) • minSdkVersion=”14” on all new projects • Leverage Gradle to create multiple versions if needed. • Do lots of tests (Hopefully automated and on devices) • Use Analytics + Crash reporting • Create a Beta community and use staged rollouts.
• Rinse and repeat 😜!28
![Page 29: Beating Android Fragmentation](https://reader034.vdocuments.site/reader034/viewer/2022052315/554fa033b4c9057b298b486b/html5/thumbnails/29.jpg)
Eventbrite Tech Talk: Android Development + Design
February 18, 2014 @ 6:30 PM
http://bit.ly/1e7oIrl
![Page 30: Beating Android Fragmentation](https://reader034.vdocuments.site/reader034/viewer/2022052315/554fa033b4c9057b298b486b/html5/thumbnails/30.jpg)
We’re hiring!
If you’re interested, let’s talk after the session
eventbrite.com/jobs
![Page 31: Beating Android Fragmentation](https://reader034.vdocuments.site/reader034/viewer/2022052315/554fa033b4c9057b298b486b/html5/thumbnails/31.jpg)
Questions?
Download our apps:
eventbrite.com/eventbriteapp