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

Developing Android App for Billions

Paresh Mayani
September 10, 2016

Developing Android App for Billions

Talk on "Developing Android application for Billions" delivered in DevFest Pune 2016 and DevFest Baroda 2016.

This deck is having android best practices to be followed and keep in mind while developing android applications.

Paresh Mayani

September 10, 2016
Tweet

More Decks by Paresh Mayani

Other Decks in Technology

Transcript

  1. Developing Android App for Billions Paresh Mayani @pareshmayani

  2. AboutMe.apk Paresh Mayani Founder/Organizer, GDG Ahmedabad Technical Lead @ Lets

    Nurture Application Architect
  3. Emerging markets will be at the forefront of smartphone growth

    80% of smartphone growth till 2019 Source : GSMA Intelligence
  4. 2016 2018 2019 Make your app work well regardless of

    how people are connected 2017 2020 47% 42% 37% 33% 29% 32% 32% 33% 34% 36% 21% 26% 29% 33% 36% Source : GSMA Intelligence 3G 4G 2G Share of mobile connections worldwide 100% 80% 60% 40% 20% 0% 1 Billion users will still be on 2G in 2020 1 Billion users will still be on 2G in 2020
  5. Tailor your app experience to variations in mobile speed and

    connection quality Source : State of the Internet Report, Q4 2015 (Akamai) 15 UK KOR JPN IND ARG 30 22.5 7.5 Mobile Connectivity 0 AUS CHN IDN ZAF EGY SAU BRA CHL 50% 100% 75% 25% 0% VNM VEN % Above 4Mbps AVG Mbps
  6. Good news: 4G is getting rolled out in India

  7. But but it would take some time to reach to

    rural areas.... Source : Giphy.com
  8. Help your users manage their data cost 3% AUS UK

    KOR EGY NGA 6% 4.5% 1.5% Post paid data prices (% of per capita GNI) Post paid data prices (% of per capita GNI) 0% Source : Measuring the Information Society Report 2015 (ITU) 4% 8% 6% 2% 0% HK CHN TH IDN MEX VNM IND BRA NOR HK UK NGA VNM AUS IDN BRA PHL IND EGY MEX KEN
  9. Active Android Users 1.4 Billion

  10. Developing for Billions Framework 1.Connectivity 2.Device Capability 3.Data Cost 4.Battery

    Consumption 5.Content 6.Commerce
  11. Developing for Billions Framework 1.Connectivity 2.Device Capability 3.Data Cost 4.Battery

    Consumption 5.Content 6.Commerce
  12. Prioritize traffic - text first De-duplicate network requests Adjust behavior

    by connection (For example, Youtube) Effective API Design (Avoid Select * ) Optimize networking
  13. Load and Display TEXTUAL data first Load Images asynchronously Prioritize

    Traffic - Text First Note: Following this would help you in making your users busy in app, and meanwhile you load the data
  14. Effective API Design At that moment when API developer writes

    “Select * from table” query and returns all the data in response
  15. Send only required fields and avoid unnecessary details Most of

    the time enemy is Select * query Can optimize APIs with “Expiry date” or “Last updated” date Effective API Design
  16. Optimize images Use Vector Images Serve dynamic image sizes No

    need to different sets of colored images, apply color filters Placeholder or low-resolution thumbnails can improve user experience
  17. ImageView is 120x120 and image resolution is 1024x768 Purely injustice

    Image should be downscaled. Use some popular libraries like Glide. They provide caching mechanism, downscaling, thumbnailing, transformations, and what not. Serve dynamic image sizes
  18. Load only Required size Cache Images Use Image loading libraries

    like Picasso, Glide, Fresco Serve dynamic image sizes
  19. Note: Not a performance tip but a good practice in

    displaying UI Picasso library provides functionality to prioritize the image loading through priority(). priority() takes one of three constants, HIGH, MEDIUM, or LOW Load Images Priority wise
  20. Useful Offline Experience Cache Image loading library

  21. Because you know Internet sucks :) and Seeing “Loading…” dialog

    is boring Caching Data
  22. Make your user’s busy Important: Display whatever data you have,

    meanwhile fetch required data Caching Data
  23. Effective cache controls will dramatically reduce server load Cache data

    as much as possible, why? Less number of web requests => No use of network radio => Improved battery life Important: It will make user busy in reading something while loading new set of data Important: Don’t assume everyone has high speed connection in the world! Caching Data
  24. Useful Offline Experience Test in airplane mode

  25. Developing for Billions Framework 1.Connectivity 2.Device Capability 3.Data Cost 4.Battery

    Consumption 5.Content 6.Commerce
  26. Screen Sizes Test with emulator configurations Build for small &

    medium screens Optimize for mdpi & hdpi Test with emulator configurations
  27. Efficient Memory Usage Adjust footprint by available RAM ActivityManager.isLowRamDevice() ActivityManager.getMemoryClass()

    Avoid long-running processes
  28. Memory Usage Android Studio memory monitor 512MB RAM 1GB RAM

    12.51MB 36.39MB
  29. Smart Storage Use Bounded caches Cache in getCacheDir() Allow install

    to SD card Measure via app settings
  30. Backwards Compatibility targetSdkVersion 23 minSdkVersion 15 Android Support libraries Google

    Play services
  31. 1.Connectivity 2.Device Capability 3.Data Cost 4.Battery Consumption 5.Content 6.Commerce Developing

    for Billions Framework
  32. Those big and bloated Apks...

  33. Those big and bloated Apks... Remember everyone doesn’t have super

    fast network?
  34. Those big and bloated Apks... Remember everyone doesn’t have super

    fast network? Then show me ways to Reduce Apk size?
  35. APK Size Images are biggest offenders Reduce code size, use

    ProGuard Set following in build.gradle minifyEnabled=true shrinkResources=true Multi-APK as an option
  36. Inspect Code...

  37. Inspect Code... Remove unused resources Optimized code Improve performance

  38. Analyze Apk

  39. Analyze Apk

  40. Analyze Apk To avoid 64K referenced method limit issues with

    your Dex files Diagnose ProGuard configuration issues View merged AndroidManifest.xml file inspect the compiled resources file (resources.arsc) Ensure your APK contains exactly the things you expect
  41. Developing for Billions Framework 1.Connectivity 2.Device Capability 3.Data Cost 4.Battery

    Consumption 5.Content 6.Commerce
  42. Battery Consumption Eliminate unneeded wakeups Batch network requests Use GcmNetworkManager

    API
  43. Developing for Billions Framework 1.Connectivity 2.Device Capability 3.Data Cost 4.Battery

    Consumption 5.Content 6.Commerce
  44. Fast & Responsive UI Touch feedback everywhere UI always interactive

    Always target 60 fps Consider launch screens Source : nkdroidsolutions.com
  45. Implementing Ripple effect <RelativeLayout android:id="@+id/rlCarDetailsPUC" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?attr/selectableItemBackground"> <android.support.v7.widget.CardView android:layout_width="match_parent"

    android:layout_height="wrap_content" app:cardCornerRadius="@dimen/dimen_5_dp" android:foreground="?attr/selectableItemBackground" app:cardElevation="@dimen/common_card_elevation" app:cardUseCompatPadding="true"> Layout - Set background CardView - Set foreground
  46. Implementing Ripple effect <TextView . . android:background="?attr/selectableItemBackgroundBorderless" android:clickable="true" /> <ImageView

    . . . android:background="?attr/selectableItemBackgroundBorderless" android:clickable="true" /> TextView - selectableItemBackgroundBorderless ImageView - Use selectableItemBackgroundBorderless
  47. Implementing Ripple effect - Button <?xml version="1.0" encoding="utf-8"?> <ripple xmlns:android="http://schemas.android.com/apk/res/android"

    android:color="@color/colorPrimaryDark"> <item android:drawable="@color/colorPrimary" /> </ripple> <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@color/colorPrimaryDark"/> <item android:drawable="@color/colorPrimary"/> </selector> drawable-v21/ drawable/
  48. Consider launch screens It’s a user’s first experience of your

    app Use a placeholder UI Or a branded launch screen
  49. UI Best Practices Adhere to Material Design Use Design Support

    library
  50. Localization Support your user’s locale User appropriate fonts (e.g. Noto)

  51. Developing for Billions Framework 1.Connectivity 2.Device Capability 3.Data Cost 4.Battery

    Consumption 5.Content 6.Commerce
  52. Monetization Advertisement In-App Purchase Subscription Paid App

  53. Local Price Sub-dollar prices available in over 18 countries Helps

    offer locally affordable products
  54. Bonus Tips

  55. Introduction Screens Don’t assume your app’s all users are literate

    Guide your users Show Important features of your app
  56. Prepare Wireframe/Mockups Because App Developers are not magicians...

  57. Prepare Wireframe/Mockups

  58. Don’t wait for your Users to submit Crash Reports At

    that moment when you users are saying app is being crashed
  59. You would not come to know about crashes being faced

    by users, until they submit voluntarily Then how to get it automatically? Use tools like Crashlytics, Firebase, Crittercism, ACRA Don’t wait for your Users to submit Crash Reports
  60. Use Version Control System Have developed scalable app Have proper

    architecture followed Use patterns => MVP / MVVM Use OkHttp, Retrofit, RxJava, RxAndroid More tips/best practices
  61. Building for Billions Playbook g.co/play/billionsplaybook What’s Next ? Building for

    Billions Framework g.co/dev/billions
  62. No Questions!

  63. Thank you! Paresh Mayani @pareshmayani