Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Managing Android Fragmentation

3ddbc5555684719ae46d67021f0dc36e?s=47 Saud Khan
October 23, 2013

Managing Android Fragmentation

Fragmentation at Twitter Scale explores what it takes to ship an Android app to hundreds of millions of users many of which are in remote corners of the world. The app needs to run a wide variety of devices, over slow or expensive connections, yet still take advantage of the latest features of Android.

In this talk, we’ll look at building different versions of the app, a light version for underpowered devices and the other one that takes advantage of the latest hardware. You will learn how Twitter automates testing across many different devices, and how to deal with edge cases with respect to NDK on different hardware.

3ddbc5555684719ae46d67021f0dc36e?s=128

Saud Khan

October 23, 2013
Tweet

More Decks by Saud Khan

Other Decks in Programming

Transcript

  1. Managing Android Fragmentation Saud Khan! @bidyut

  2. None
  3. Agenda • Various fragmentation points • Battles we fought at

    Twitter • Steps to take to make life easier • Q&A
  4. Devices Courtesy: OpenSignal.com

  5. Screen Sizes Courtesy: OpenSignal.com

  6. Manufacturers Courtesy: OpenSignal.com

  7. Hardware • Hardware buttons • Hardware keyboard • Camera support

    • Various sensors
  8. Android Stack Courtesy: developer.android.com

  9. Twitter Users 11/11/11 11:11

  10. Twitter Android Users

  11. Global Town Square

  12. How do we manage?

  13. 3 Questions • What are the key features of the

    app? • What minimum API level are these features available at? • What legacy devices are you comfortable leaving behind?
  14. Twitter Android Users

  15. Who do we support? • Froyo and up • Eclair

    in maintenance
  16. Android for All • Target MDPI (medium density) • Only

    include assets for MDPI • No support for photo filters
  17. Android for All APK size of around 4 MB

  18. Where do we start?

  19. Quick Wins • Screen sizes and orientation • Density-independent pixel

    (dp) • Scale-independent pixel (sp)
  20. 1080p 720p

  21. Quick wins • Screen sizes and orientation • Density-independent pixel

    (dp) • Scale-independent pixel (sp) • Multiple languages
  22. Multiple Languages Courtesy: UNESCO

  23. Example Tweet <style name="UserImage"> <item name="android:layout_width">@dimen/user_image_size</item> <item name="android:layout_height">@dimen/user_image_size</item> <item name="android:layout_marginRight">@dimen/list_row_padding</item>

    <item name="android:layout_alignParentLeft">true</item> </style>
  24. Example Tweet <style name="UserImage.RTL"> <item name="android:layout_marginRight">0dp</item> <item name="android:layout_marginLeft">@dimen/list_row_padding</item> <item name="android:layout_alignParentLeft">false</item>

    <item name="android:layout_alignParentRight">true</item> </style>
  25. layout/user_info.xml <?xml  version="1.0"  encoding="utf-­‐8"?>   <merge  xmlns:android="http://schemas.android.com/apk/res/android">      

       <ImageView  android:id="@id/user_image"                                style="@style/UserImage"/>          <RelativeLayout  android:layout_toRightOf="@id/user_image"                                          android:layout_toLeftOf="@id/action_button"                                          android:layout_centerVertical="true"                                          android:layout_width="wrap_content"                                          android:layout_height="wrap_content">                  <include  layout="@layout/user_info_name"/>                  <com.twitter.library.widget.TypefacesTextView                                  android:id="@+id/screenname_item"                                  android:layout_below="@id/name_layout"                                  style="@style/Username"/>          </RelativeLayout>   </merge>
  26. layout-ar-v15/user_info.xml <?xml  version="1.0"  encoding="utf-­‐8"?>   <merge  xmlns:android="http://schemas.android.com/apk/res/android">      

       <ImageView  android:id="@id/user_image"                                style="@style/UserImage.RTL"/>          <RelativeLayout  android:layout_toLeftOf="@id/user_image"                                          android:layout_toRightOf="@id/action_button"                                          android:layout_centerVertical="true"                                          android:layout_width="wrap_content"                                          android:layout_height="wrap_content">                  <include  layout="@layout/user_info_name"/>                  <com.twitter.library.widget.TypefacesTextView                                  android:id="@+id/screenname_item"                                  android:layout_below="@id/name_layout"                                  style="@style/Username"/>          </RelativeLayout>   </merge>
  27. Right-To-Left • Jellybean and newer • Different language codes •

    Arabic (ar) • Farsi (fa) • Hebrew (iw, he)
  28. Debug mode

  29. Quick wins • Screen sizes and orientation • Density-independent pixel

    (dp) • Scale-independent pixel (sp) • Multiple languages • Android Support libraries
  30. ViewPager

  31. Let the tools do the heavy lifting

  32. ActionBar

  33. ActionBar • No support in Gingerbread • No expansion in

    Honeycomb • Differences in Ice Cream Sandwich and Jellybean
  34. Jellybean • Utilizing ActionBar

  35. Gingerbread • Old title bar look • Custom expanded look

  36. Honeycomb • Utilizing ActionBar • Native Android search

  37. public  static  ActionBarHelper  newInstance(Activity  activity)  {        

     if  (Build.VERSION.SDK_INT  <  Build.VERSION_CODES.HONEYCOMB)  {                  return  new  ActionBarHelperCompat(activity);          }  else  if  (Build.VERSION.SDK_INT  <                                Build.VERSION_CODES.ICE_CREAM_SANDWICH)  {                  return  new  ActionBarHelperHoneycomb(activity);          }  else  {                  return  new  ActionBarHelperICS(activity);          }   }
  38. Hardware buttons • Search button vs Action Bar • Menu

    button vs Overflow menu
  39. Database • Different versions of SQLite • Test with the

    lowest supporting API
  40. • Improving DB queries by joining tables instead of views

    • Wasn’t a good idea for complicated joins under Eclair
  41. Native Libraries • A set for each architecture • Size

    vs Complexity
  42. Photo filters • Issues with different photos • Random failures

    in native code • Exceptions for various unique devices
  43. What’s next?

  44. Testing • Multi API level testing • Multiple languages •

    Various OEM devices • UI automation
  45. Support • Crashlytics • Listen to the feed

  46. Crashlytics

  47. Build Tools • Android for All • Beta, Release •

    Gradle flavors
  48. Versioning • Numeric name spacing • OOSSDDVVV • OS API

    level • Screen size • Display Density • Version Courtesy: developer.android.com
  49. Versioning • 070001050 • 100000050 • 140000050 • 070001054! •

    100000075! • 140000051
  50. Thank you @bidyut