Save 37% off PRO during our Black Friday Sale! »

Droidcon Montreal 2015: Optimizing Your Apps For Emerging Markets

Droidcon Montreal 2015: Optimizing Your Apps For Emerging Markets

Talk that I gave at Droidcon Montreal 2015 about ways in which you can optimize your apps for markets which are driving the growth of smartphones.

E8da8d13d06ca69dbe019ecad71ed2a4?s=128

vinaygaba

May 15, 2015
Tweet

Transcript

  1. Optimizing Your Apps For Emerging Markets #DroidconMtl

  2. None
  3. Emerging Markets Drive Growth

  4. Source: Mediacells via The Guardian

  5. Source: Mediacells via The Guardian

  6. 44 36 21 51 37 11 80 10 9 25

    66 9 Smartphone Feature phone Multimedia phone Brazil Russia India China
  7. 1. Optimizing App Size

  8. The smaller, the better

  9. Color Filters

  10. Use Color Filter • Faster way to experiment with color

    schemes. • Reduce the number of assets, which in turn reduc the apk size. • Less memory used as the number of assets are reduced.
  11. Code ImageView redCircle = (ImageView) findV iewById(R.id.circle_red_imageview); ImageView greenCircle =

    (ImageView) findV iewById(R.id.circle_green_imageview); ImageView blueCircle = (ImageView) findV iewById(R.id.circle_blue_imageview); // we can create the color values in different ways: redCircle.getDrawable().setColorFilter(C olor.RED, PorterDuff.M ode.M U LTIPLY ); greenCircle.getDrawable().setColorFilter(0xff00ff00, PorterDuff.M ode.M U LTIPLY ); blueCircle.getDrawable().setColorFilter(getResources().getColor(R.color.blue),PorterDuff.M ode. M U LTIPLY );
  12. Image Optimizations Color Filters

  13. JPEG WEBP PNG GIF Lossy Lossless Transparenc y Animation WebP

  14. No Noticeable Change PNG 24 kb WebP 10 kb

  15. Compatibility • You can use the native WebP decoder on

    4.2 and later. • For lower versions, use libpng to convert to PNG format and then use it in the app.
  16. Other Libraries • Use programs like OptiPNG, TruePNG and PNGC

    to significantly reduce the size of PNG images. • Use mozjpeg for jpeg images. • 5-10% size reduction • Won’t cause any visible changes to the images.
  17. Remove Unused Content Image Optimizations Color Filters

  18. Remove Unused Content • Use Resource Shrinking.

  19. Code android { ... buildTypes { release { minifyEnabled true

    shrinkResources true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } }
  20. Remove Unused Content • Use Resource Shrinking. • Use tools

    like Lint and ProGuard. • Use Android-Unused-Resources jar file if you are still using Eclipse. https://code.google.com/p/android-unused-resources/
  21. 2. Optimizing Network Calls

  22. Expensive Data Flaky Networks Challenges

  23. Build for Failure

  24. Most efficient way to transfer is to not transfer

  25. Image Scaling

  26. Appropriate Image Size • Store multiple image sizes on the

    server • Low-res devices might never need a full resolutio image • Most times the smallest image size is sufficient.
  27. None
  28. Checksum Image Scaling

  29. Client A Client B Server Checksum ID Send File ID

    Transfer File CS ID
  30. Code public static String getM D5EncryptedString(String encTarget){ M essageDigest mdEnc

    = null; mdEnc = M essageDigest.getInstance("M D5"); // Encryption algorithm mdEnc.update(encTarget.getBytes(), 0, encTarget.length()); String md5 = new BigInteger(1, mdEnc.digest()).toString(16); while ( md5.length() < 32 ) { md5 = "0"+md5; } return md5; }
  31. Checksum • Avoid transfers as much as possible. • For

    file transfers, first compute the md5 checksum and send it to the server to check if it already exis on the server. • The cost to upload the entire file again can be avoided.
  32. Image Scaling Checksum Transfer in Blocks

  33. Transfer in blocks • Do data transfers in blocks. •

    Keep track of the blocks that have been transferre and yet to be transferred. • The block size can vary based on the type of connection.
  34. Testing for different networks is a pain

  35. Testing for different networks • Facebook recently open-sourced Augmented Traf

    Control (ATC). • It is a tool to simulate network conditions. • It can simulate 2G, Edge, 3G, and LTE networks. • Has multiple profiles for a lot of different countri http://facebook.github.io/augmented-traffic-control/
  36. 3. Optimizing for Differen Phones

  37. Small Screens Slow Processing Challenges

  38. Developing for flagship devices is easy

  39. Year Class

  40. None
  41. Code int year = Y earC lass.get(getA pplicationContext()); if (year

    >= 2013) { // Do advanced animation } else if (year > 2010) { // Do simple animation } else { // Phone too slow, don't do any animations } https://github.com/facebook/device-year-class
  42. Redesign Year Class

  43. Redesign • Remove features from low-end devices if they wo

    have the best user experience. • This could be animations, videos or even functionalities. • No feature >>> Bad feature
  44. @vinaygaba Questions?