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

    View Slide

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

    View Slide

  3. Emerging markets will
    be at the forefront of
    smartphone growth
    80%
    of smartphone
    growth till
    2019
    Source : GSMA
    Intelligence

    View Slide

  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

    View Slide

  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

    View Slide

  6. Good news: 4G is getting rolled out in India

    View Slide

  7. But but it would take some time to reach to rural areas....
    Source : Giphy.com

    View Slide

  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

    View Slide

  9. Active Android Users
    1.4
    Billion

    View Slide

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

    View Slide

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

    View Slide

  12. Prioritize traffic - text first
    De-duplicate network requests
    Adjust behavior by connection (For example, Youtube)
    Effective API Design (Avoid Select * )
    Optimize networking

    View Slide

  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

    View Slide

  14. Effective API Design
    At that moment when API developer writes “Select * from table” query and
    returns all the data in response

    View Slide

  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

    View Slide

  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

    View Slide

  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

    View Slide

  18. Load only Required size
    Cache Images
    Use Image loading libraries like Picasso, Glide, Fresco
    Serve dynamic image sizes

    View Slide

  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

    View Slide

  20. Useful Offline Experience
    Cache
    Image loading library

    View Slide

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

    View Slide

  22. Make your user’s busy
    Important: Display whatever data you have, meanwhile fetch required data
    Caching Data

    View Slide

  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

    View Slide

  24. Useful Offline Experience
    Test in airplane mode

    View Slide

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

    View Slide

  26. Screen Sizes
    Test with emulator configurations
    Build for small & medium screens
    Optimize for mdpi & hdpi
    Test with emulator configurations

    View Slide

  27. Efficient Memory Usage
    Adjust footprint by available RAM
    ActivityManager.isLowRamDevice()
    ActivityManager.getMemoryClass()
    Avoid long-running processes

    View Slide

  28. Memory Usage
    Android Studio memory monitor
    512MB RAM 1GB RAM
    12.51MB 36.39MB

    View Slide

  29. Smart Storage Use
    Bounded caches
    Cache in getCacheDir()
    Allow install to SD card
    Measure via app settings

    View Slide

  30. Backwards Compatibility
    targetSdkVersion 23
    minSdkVersion 15
    Android Support libraries
    Google Play services

    View Slide

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

    View Slide

  32. Those big and bloated Apks...

    View Slide

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

    View Slide

  34. Those big and bloated Apks...
    Remember everyone doesn’t have super fast network?
    Then show me ways to Reduce Apk size?

    View Slide

  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

    View Slide

  36. Inspect Code...

    View Slide

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

    View Slide

  38. Analyze Apk

    View Slide

  39. Analyze Apk

    View Slide

  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

    View Slide

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

    View Slide

  42. Battery Consumption
    Eliminate unneeded wakeups
    Batch network requests
    Use GcmNetworkManager API

    View Slide

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

    View Slide

  44. Fast & Responsive UI
    Touch feedback everywhere
    UI always interactive
    Always target 60 fps
    Consider launch screens
    Source : nkdroidsolutions.com

    View Slide

  45. Implementing Ripple effect
    android:id="@+id/rlCarDetailsPUC"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?attr/selectableItemBackground">
    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

    View Slide

  46. Implementing Ripple effect
    .
    .
    android:background="?attr/selectableItemBackgroundBorderless"
    android:clickable="true"
    />
    .
    .
    .
    android:background="?attr/selectableItemBackgroundBorderless"
    android:clickable="true"
    />
    TextView - selectableItemBackgroundBorderless
    ImageView - Use selectableItemBackgroundBorderless

    View Slide

  47. Implementing Ripple effect - Button

    xmlns:android="http://schemas.android.com/apk/res/android"
    android:color="@color/colorPrimaryDark">



    xmlns:android="http://schemas.android.com/apk/res/android">
    android:drawable="@color/colorPrimaryDark"/>


    drawable-v21/
    drawable/

    View Slide

  48. Consider launch screens
    It’s a user’s first experience of your app
    Use a placeholder UI
    Or a branded launch screen

    View Slide

  49. UI Best Practices
    Adhere to Material Design
    Use Design Support library

    View Slide

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

    View Slide

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

    View Slide

  52. Monetization
    Advertisement
    In-App Purchase
    Subscription
    Paid App

    View Slide

  53. Local Price
    Sub-dollar prices available in over 18 countries
    Helps offer locally affordable products

    View Slide

  54. Bonus Tips

    View Slide

  55. Introduction Screens
    Don’t assume your app’s all users are literate
    Guide your users
    Show Important features of your app

    View Slide

  56. Prepare Wireframe/Mockups
    Because App Developers are not magicians...

    View Slide

  57. Prepare Wireframe/Mockups

    View Slide

  58. Don’t wait for your Users to submit Crash Reports
    At that moment when you users are saying app is being crashed

    View Slide

  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

    View Slide

  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

    View Slide

  61. Building for Billions Playbook
    g.co/play/billionsplaybook
    What’s Next ?
    Building for Billions Framework
    g.co/dev/billions

    View Slide

  62. No
    Questions!

    View Slide

  63. Thank you!
    Paresh Mayani
    @pareshmayani

    View Slide