tools and libraries for common problems (early draft)

63
Android Libraries: Pros, Cons, and Gotchas By Ryan Cooke

Upload: rc2209

Post on 06-Apr-2017

31 views

Category:

Software


1 download

TRANSCRIPT

Page 1: Tools and libraries for common problems (Early Draft)

Android Libraries: Pros, Cons, and Gotchas

By Ryan Cooke

Page 2: Tools and libraries for common problems (Early Draft)

This is Important● Long term consequence● Months productivity● Google expects it

“If that ecosystem is already enabled, what value are we adding by just adding something else to it?”

- Chet Haase

Page 3: Tools and libraries for common problems (Early Draft)

General Tips● Reversibility● Wrapper

Page 4: Tools and libraries for common problems (Early Draft)

General Tips● Unit Test 3rd Party Libraries● Method Count

○ Methods Count○ Dex-method-counts○ Apk-method-count○ Pull out the core of the library

● Popular & Mature Libraries● Beware of Unusual Approaches

Page 5: Tools and libraries for common problems (Early Draft)

Social Login● Facebook

○ Test Users○ Email not guaranteed○ Key hashes○ Review is a pain○ Log errors

Page 6: Tools and libraries for common problems (Early Draft)

Social Login● Twitter

○ Not very popular <2%○ https://support.twitter.com/forms/platform

● LinkedIn○ Not very popular <2%○ Challenging api

● Google○ Multiple email choices○ Design limitations○ Works well with smart lock

Page 7: Tools and libraries for common problems (Early Draft)

Login Various● Smart Lock

○ Email Hint○ Cross platform○ Great experience ideal case○ Not on iOS○ Assets.json requires server upload

Page 8: Tools and libraries for common problems (Early Draft)

Networking● Retrofit● Volley

● OkHttp○ Behind the scenes○ Android 4.4

Page 9: Tools and libraries for common problems (Early Draft)

Networking Debugging - Stetho

Page 10: Tools and libraries for common problems (Early Draft)

Network Debugging - HttpLoggingInterceptor

Page 11: Tools and libraries for common problems (Early Draft)

Images● Picasso

○ Very small library (2.5.2/849) ○ Simple to Use

● Glide○ Gif support○ Various nice to haves○ Larger (3.7.0/2879)

● Tips○ Prefetch on lists○ Memory

■ Profile■ Resize

● Cloudinary■ Bytes used = pixel width * pixel height * 4■ largeHeap (Large Heap App Detector)

Page 12: Tools and libraries for common problems (Early Draft)

ARGB_8888 RGB_565

Page 13: Tools and libraries for common problems (Early Draft)

Images - Fresco● Magic memory cleverness

○ Pre-lollipop (api 21)

● Progressive jpg● Drawees instead of imageViews

Page 14: Tools and libraries for common problems (Early Draft)

Memory - Leaks● Leak Canary

○ Difficult to read○ Not easiest to share○ Don’t forget to set watchers

●●●●●● WeakHandler

Page 15: Tools and libraries for common problems (Early Draft)

UI● Activities

○ Where it all began

● Fragments○ Solution or Problem?

● Views○ Swap content of frame layout

Page 16: Tools and libraries for common problems (Early Draft)

View-Based-Architecture● Mortar + Flow

○ MVP○ Lacks solutions to common issues

● Conductor○ Built solving common view based

architecture issues

● Scoop○ Limited Transition○ Can’t Save State○ Most Production Tested

Page 17: Tools and libraries for common problems (Early Draft)

Model View Presenter (MVP)● Mosby

○ Tutorial○ ViewState

● Nucleus● Mortar● Build it yourself

Page 18: Tools and libraries for common problems (Early Draft)

Testing - Unit Testing● MVP (Model View Presenter)● Dependency Injection (DI)● Roboelectirc

○ Rewrote core android libraries with shadow classes

● Junit4○ Assertj-Android○ MoreAsserts○ ViewAsserts

Page 19: Tools and libraries for common problems (Early Draft)

Testing - Instrumentation Testing● Espresso

○ Espresso Screen Recorder

● Inferior options● okhttp/mockwebserver

Page 20: Tools and libraries for common problems (Early Draft)

Device Labs● Have your own

○ Spoon

● AWS Device Farm○ $0.17 per minute ($250/mo unlimited 1

device)

● Firebase○ $5 per device hour physical, $1 per hour

virtual

● Lots of others

Page 21: Tools and libraries for common problems (Early Draft)

Build Systems● Jenkins● BuddyBuild● CircleCI

Page 22: Tools and libraries for common problems (Early Draft)

Build System Extras● Checkstyle

○ Use the plugin○ Enforce style in your team

● Findbugs○ Bytecode

● PMD○ Source code

● Android Lint○ Lots of hidden capabilities

● Autoformatter○ Fix style no enforcement needed

Page 23: Tools and libraries for common problems (Early Draft)

Testing - Performance - NimbeDroid

Page 24: Tools and libraries for common problems (Early Draft)

Database - SQL● SQLite● SQLBrite

○ Reactive sqlIte○ Update with changes

● SQLDelight○ Work with SQL easier○ Organizing sql statements○ TypeSafe Api for read/write

● ORMs○ GreenDAO○ OrmLite○ DBFlow

Page 25: Tools and libraries for common problems (Early Draft)

Database - NoSQL● Realm

○ Documentation and support○ Is super fast

● LevelDB○ Key-Value pair by Google

Page 26: Tools and libraries for common problems (Early Draft)

Database - Mobile Platform● Firebase● Realm

○ Offline first

Page 27: Tools and libraries for common problems (Early Draft)

● Gson● Jackson● Moshi● LoganSquare

○ Compile time work

● Flatbuffer○ Json alternative

Json

Page 28: Tools and libraries for common problems (Early Draft)

Deeplinking● Services

○ Yozio○ Branch○ Firebase Dynamic

Links

● App link● Deep Link Dispatch

Page 29: Tools and libraries for common problems (Early Draft)

Analytics● Wrapping 3rd party tools● Log screens● If you can measure you can

optimize● Don’t get lost

○ Adding too many○ Untested○ Confusing naming○ Delaying easy decisions○ Finding too large of conclusions

Page 30: Tools and libraries for common problems (Early Draft)

Analytics - Firebase● Firebase Analytics

○ Underlies all of firebase○ Free○ Actively Improving

Page 31: Tools and libraries for common problems (Early Draft)

Analytics● Google Analytics

○ Basic○ Behavior Flow

● Play Store Console○ Basic Core Questions

● Answers○ Great for the office tv

● Mixpanel○ Paid, but very good

● Lots more

Page 32: Tools and libraries for common problems (Early Draft)

Attribution● Adjust

○ For when Facebook makes attribution hard

● Play Store Url builder○ https://play.google.com/store/apps/details?id=com.exa

mple.application&referrer=utm_source%3Dgoogle%26utm_medium%3Dcpc%26utm_campaign%3Dspring_sale

adb shell am broadcast -a com.android.vending.INSTALL_REFERRER -n <your.package>/.<path.up.until.your.BroadcastReceiver> --es "referrer" "utm_source=test_source\&utm_medium=test_medium\&utm_term=test_term\&utm_content=test_content\&utm_campaign=test_name"

Page 33: Tools and libraries for common problems (Early Draft)

A/B Testing● Disclaimer

○ Overhyped○ Slow learning○ Great for making bugs

● Services○ Optimizely○ Firebase Remote Config○ Apptimize

● Store Listing

Page 34: Tools and libraries for common problems (Early Draft)

Crash Reporting● Play Store

○ Misses most crashes○ Occasionally very useful

● Crashlytics○ Free

● Bugsnag○ Paid○ Query crashes

● Instabug or Telescope○ Easy to report bugs

Page 35: Tools and libraries for common problems (Early Draft)

Feedback● Zendesk● Intercom● Android-Rate

○ Strategic review prompt○ Non 5 star reviews to feedback○ Significantly more reviews

Page 36: Tools and libraries for common problems (Early Draft)

Push Notifications● GCM/FCM

○ Not great for marketing people

● Analytic Services○ Firebase Notifications○ Mixpanel

● Push Services○ UrbanAirship○ Kahuna

■ AI

Page 37: Tools and libraries for common problems (Early Draft)

Other Notifications● Email

○ Campaign■ MailChimp

○ Interaction■ SendGrid■ ManDrill■ MailGun

● SMS○ Twilio

Page 38: Tools and libraries for common problems (Early Draft)

Easier● Butterknife

○ Zelezny

● Hugo● Dart & Henson● Retrolambda

Page 39: Tools and libraries for common problems (Early Draft)

Harder (at First)● RxJava

○ React to stuff○ Learning curve○ Misused

● Kotlin○ Cleaner code○ Null pointer○ New language

● EventBus

Page 40: Tools and libraries for common problems (Early Draft)

Logging● Logger

○ Pretty logs

● Timber○ Custom logging behavior○ Combined logging options

Page 41: Tools and libraries for common problems (Early Draft)

Camera● Camera Intent● Material

Camera○ Easy to fork

● Android Crop

Page 42: Tools and libraries for common problems (Early Draft)

Thinking Globally● Network Emulation

○ Emulator○ Charles Proxy○ Augmented Traffic Control (ATC)

● AutoFitTextView● Year Class

○ 2015 is the max

● Connection Class○ Sampling is wonky

Page 43: Tools and libraries for common problems (Early Draft)

Android-KnitHave lunch with Pinterest Android

Page 45: Tools and libraries for common problems (Early Draft)

Video● ExoPlayer

○ DASH (adaptive bitrate streaming)○ SmoothStreaming○ Customizable○ API 16

● YouTube ○ Easy○ SEO

Page 46: Tools and libraries for common problems (Early Draft)

Building the app● Gradle

○ Staying standard is good

● OkBuck○ Converts Gradle to Buck

● Buck● Bazel

Page 47: Tools and libraries for common problems (Early Draft)

Building the app● Instant Run

○ Doesn’t work

● JRebel○ First run is very slow○ Does work○ Annotation processing on incremental

build for popular libraries○ 14 day free trial

● hannesstruss/godot○ Track time lost to builds

Page 48: Tools and libraries for common problems (Early Draft)

Emulator● Genymotion● Native (Avd)

○ Generally comparable to genymotion and free

Page 49: Tools and libraries for common problems (Early Draft)

Dependency Injection● Dagger 2● Dagger 1

○ Like Dagger 2, but slower

● Roboguice○ Like Dagger 1, but slower

Page 50: Tools and libraries for common problems (Early Draft)

Social Login● Easier to implement● More secure● Easier to signup● More information on signup

Page 51: Tools and libraries for common problems (Early Draft)

Layout Processor● Anko

○ 400% faster■ No Benchmarks

○ Newer devices handful of ms○ No Preview○ Kotlin

Page 52: Tools and libraries for common problems (Early Draft)

Login● Firebase Auth UI

○ Limited Properties○ Vendor Lock

● AuthZero○ Better UI○ Costs Money

Page 53: Tools and libraries for common problems (Early Draft)

Memory● Memory Monitor● Hprof

Page 54: Tools and libraries for common problems (Early Draft)

Images - Memory● Profile● Resize● Width * Height * 4

Page 55: Tools and libraries for common problems (Early Draft)

Images - Memory● android:largeHeap=”true”

○ Large Heap App Detector

● drawable-nodpi

Page 56: Tools and libraries for common problems (Early Draft)

Referral● Firebase Invites● Do It Yourself

Page 57: Tools and libraries for common problems (Early Draft)

Maps● AirMapView

○ Chooses the best map

● Google Maps

Page 58: Tools and libraries for common problems (Early Draft)

Obfuscation● Proguard

○ Shrinks○ Optimizes○ Obfuscates

■ Mapping

● Dexguard○ Obfuscation

Page 59: Tools and libraries for common problems (Early Draft)

Chat● Layer

○ Handle everything○ Very custom

● Sinch○ Great Support○ Doesn’t solve all problems○ 1 on 1 chat

● PubNub○ Built for real time

● Firebase○ Misses lots of flare

● Twilio● Chateau

Page 60: Tools and libraries for common problems (Early Draft)

Text● Calligraphy

○ Font

● Android AutoFitTextView

Page 61: Tools and libraries for common problems (Early Draft)

Date & Time● Joda Time

○ Joda-time-android○ Java devs goto fix for Date

● ThreeTenABP○ Java 8 solution

● Java 8○ Doesn’t have improvements

Page 62: Tools and libraries for common problems (Early Draft)

Payment● Stripe● Braintree

○ Braintree cc

● Card.io

Page 63: Tools and libraries for common problems (Early Draft)

Graphs● Spark● MPAndroidChart