Developing for Android

1fa9cb8c7997c8c4d3d251fb5e41f749?s=47 Realm
November 30, 2015

Developing for Android

Presented by Chet Haase and Romain Guy at Bay Area Android Developer Group on November 30, 2015

1fa9cb8c7997c8c4d3d251fb5e41f749?s=128

Realm

November 30, 2015
Tweet

Transcript

  1. Romain Guy Chet Haase Developing for Android +RomainGuy, @romainguy +ChetHaase,

    @chethaase Development for Developers by Developers Managers
  2. Developing for Android medium.com @chethaase

  3. Why is Mobile Development So Difficult?

  4. • Limited • Shared Memory

  5. • Slower than desktop & server • Throttled CPU Much

  6. • [See previous slide] • Texture uploads are expensive •

    Fill rate vs. density GPU
  7. • Larger application heaps lead to • More task thrashing

    • Slower allocations • Slower collections • More garbage collector activity Memory == Performance
  8. Allocate Enumerate Mark Collect

  9. Allocate Enumerate Mark Collect Pause Pause Dalvik

  10. Allocate Enumerate Mark Collect Pause ART

  11. Slot Available Slot Freed

  12. Slot Available Oh Noze! Slot Freed Pause GC_FOR_ALLOC

  13. ART

  14. • Your device is faster than your users’ • And

    has more memory • Moore’s Law does not always apply Low-End Devices
  15. • You have 16ms per frame • To do everything

    • Consistency is good Smooth Frame Rate
  16. • Dalvik vs. ART • Language != runtime != hardware

    Runtime
  17. Language != Platform Java programming language Runtime Hardware

  18. Server-Land Moving, compacting collector CPU: Memory: very very fast Basically

    ∞ Java programming language Server runtime Server
  19. Android No compaction Idle compaction CPU: wayyyy slower Memory: 512MB

    - 2GB Java programming language ART Mobile Dalvik
  20. • Android is single-threaded UI system • (mostly) • Eliminate

    unnecessary work on UI thread UI Thread
  21. • Storage performance varies • Storage size varies • So

    apk size matters Storage
  22. • Your network is faster than your users’ • And

    maybe cheaper, too Network
  23. • Every Device is a Village • Tragedy of the

    Commons And Finally
  24. Language & libraries

  25. • Don’t use serialization • Use Android data structures •

    Be mindful of XML and JSON usage • Avoid JNI • Primitives vs boxed primitives • Avoid reflection • Be careful with finalizers Know Your Language
  26. Networking

  27. • Don’t over-sync • Allow delayed downloading • Google Cloud

    Messaging • GCM Network Manager (Job Scheduler) • Don’t poll • Only sync what you need to Syncing
  28. • Don’t assume anything about the network • Develop for

    low-end networks • And test for them, too Network quality
  29. • Design back-end APIs for mobile usage patterns • Minimize

    and compress data Data & protocols
  30. Storage

  31. • Don’t hard-code file paths • Persist relative paths only

    • Use storage cache for temp files • Avoid SQLite for simple needs • Avoid using too many databases • Let user choose content storage location Random stuff about storage
  32. Romain Guy Chet Haase Developing for Android +RomainGuy, @romainguy +ChetHaase,

    @chethaase Development for Developers by Developers Q & A