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

Managing Android Fragmentation

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.

Saud Khan

October 23, 2013
Tweet

More Decks by Saud Khan

Other Decks in Programming

Transcript

  1. Agenda • Various fragmentation points • Battles we fought at

    Twitter • Steps to take to make life easier • Q&A
  2. 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?
  3. Android for All • Target MDPI (medium density) • Only

    include assets for MDPI • No support for photo filters
  4. Quick wins • Screen sizes and orientation • Density-independent pixel

    (dp) • Scale-independent pixel (sp) • Multiple languages
  5. 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>
  6. 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>
  7. Right-To-Left • Jellybean and newer • Different language codes •

    Arabic (ar) • Farsi (fa) • Hebrew (iw, he)
  8. Quick wins • Screen sizes and orientation • Density-independent pixel

    (dp) • Scale-independent pixel (sp) • Multiple languages • Android Support libraries
  9. ActionBar • No support in Gingerbread • No expansion in

    Honeycomb • Differences in Ice Cream Sandwich and Jellybean
  10. 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);          }   }
  11. • Improving DB queries by joining tables instead of views

    • Wasn’t a good idea for complicated joins under Eclair
  12. Photo filters • Issues with different photos • Random failures

    in native code • Exceptions for various unique devices
  13. Versioning • Numeric name spacing • OOSSDDVVV • OS API

    level • Screen size • Display Density • Version Courtesy: developer.android.com