tools and libraries for common problems (early draft)
TRANSCRIPT
Android Libraries: Pros, Cons, and Gotchas
By Ryan Cooke
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
General Tips● Reversibility● Wrapper
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
Social Login● Facebook
○ Test Users○ Email not guaranteed○ Key hashes○ Review is a pain○ Log errors
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
Login Various● Smart Lock
○ Email Hint○ Cross platform○ Great experience ideal case○ Not on iOS○ Assets.json requires server upload
Networking● Retrofit● Volley
● OkHttp○ Behind the scenes○ Android 4.4
Networking Debugging - Stetho
Network Debugging - HttpLoggingInterceptor
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)
ARGB_8888 RGB_565
Images - Fresco● Magic memory cleverness
○ Pre-lollipop (api 21)
● Progressive jpg● Drawees instead of imageViews
Memory - Leaks● Leak Canary
○ Difficult to read○ Not easiest to share○ Don’t forget to set watchers
●●●●●● WeakHandler
UI● Activities
○ Where it all began
● Fragments○ Solution or Problem?
● Views○ Swap content of frame layout
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
Model View Presenter (MVP)● Mosby
○ Tutorial○ ViewState
● Nucleus● Mortar● Build it yourself
Testing - Unit Testing● MVP (Model View Presenter)● Dependency Injection (DI)● Roboelectirc
○ Rewrote core android libraries with shadow classes
● Junit4○ Assertj-Android○ MoreAsserts○ ViewAsserts
Testing - Instrumentation Testing● Espresso
○ Espresso Screen Recorder
● Inferior options● okhttp/mockwebserver
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
Build Systems● Jenkins● BuddyBuild● CircleCI
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
Testing - Performance - NimbeDroid
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
Database - NoSQL● Realm
○ Documentation and support○ Is super fast
● LevelDB○ Key-Value pair by Google
Database - Mobile Platform● Firebase● Realm
○ Offline first
● Gson● Jackson● Moshi● LoganSquare
○ Compile time work
● Flatbuffer○ Json alternative
Json
Deeplinking● Services
○ Yozio○ Branch○ Firebase Dynamic
Links
● App link● Deep Link Dispatch
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
Analytics - Firebase● Firebase Analytics
○ Underlies all of firebase○ Free○ Actively Improving
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
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"
A/B Testing● Disclaimer
○ Overhyped○ Slow learning○ Great for making bugs
● Services○ Optimizely○ Firebase Remote Config○ Apptimize
● Store Listing
Crash Reporting● Play Store
○ Misses most crashes○ Occasionally very useful
● Crashlytics○ Free
● Bugsnag○ Paid○ Query crashes
● Instabug or Telescope○ Easy to report bugs
Feedback● Zendesk● Intercom● Android-Rate
○ Strategic review prompt○ Non 5 star reviews to feedback○ Significantly more reviews
Push Notifications● GCM/FCM
○ Not great for marketing people
● Analytic Services○ Firebase Notifications○ Mixpanel
● Push Services○ UrbanAirship○ Kahuna
■ AI
Other Notifications● Email
○ Campaign■ MailChimp
○ Interaction■ SendGrid■ ManDrill■ MailGun
● SMS○ Twilio
Easier● Butterknife
○ Zelezny
● Hugo● Dart & Henson● Retrolambda
Harder (at First)● RxJava
○ React to stuff○ Learning curve○ Misused
● Kotlin○ Cleaner code○ Null pointer○ New language
● EventBus
Logging● Logger
○ Pretty logs
● Timber○ Custom logging behavior○ Combined logging options
Camera● Camera Intent● Material
Camera○ Easy to fork
● Android Crop
Thinking Globally● Network Emulation
○ Emulator○ Charles Proxy○ Augmented Traffic Control (ATC)
● AutoFitTextView● Year Class
○ 2015 is the max
● Connection Class○ Sampling is wonky
Android-KnitHave lunch with Pinterest Android
Video● ExoPlayer
○ DASH (adaptive bitrate streaming)○ SmoothStreaming○ Customizable○ API 16
● YouTube ○ Easy○ SEO
Building the app● Gradle
○ Staying standard is good
● OkBuck○ Converts Gradle to Buck
● Buck● Bazel
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
Emulator● Genymotion● Native (Avd)
○ Generally comparable to genymotion and free
Dependency Injection● Dagger 2● Dagger 1
○ Like Dagger 2, but slower
● Roboguice○ Like Dagger 1, but slower
Social Login● Easier to implement● More secure● Easier to signup● More information on signup
Layout Processor● Anko
○ 400% faster■ No Benchmarks
○ Newer devices handful of ms○ No Preview○ Kotlin
Login● Firebase Auth UI
○ Limited Properties○ Vendor Lock
● AuthZero○ Better UI○ Costs Money
Memory● Memory Monitor● Hprof
Images - Memory● Profile● Resize● Width * Height * 4
Images - Memory● android:largeHeap=”true”
○ Large Heap App Detector
● drawable-nodpi
Referral● Firebase Invites● Do It Yourself
Maps● AirMapView
○ Chooses the best map
● Google Maps
Obfuscation● Proguard
○ Shrinks○ Optimizes○ Obfuscates
■ Mapping
● Dexguard○ Obfuscation
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
Text● Calligraphy
○ Font
● Android AutoFitTextView
Date & Time● Joda Time
○ Joda-time-android○ Java devs goto fix for Date
● ThreeTenABP○ Java 8 solution
● Java 8○ Doesn’t have improvements
Payment● Stripe● Braintree
○ Braintree cc
● Card.io
Graphs● Spark● MPAndroidChart