2. DroidCon
2
• To support the Android platform and create a global network for
developers and companies
• First DroidCons at Berlin and London, 2009
• Held in Amsterdam, Bangalore, Berlin, Brussels, Bucharest, Dubai,
London, Madrid, Moscow, Montreal, Murcia, Paris, Stockholm, Tel Aviv,
NewYork, Krakow, Zagreb, Thessaloniki, San Francisco, Tunis and
Turin
• Ones, Held in Ankara, Android Developer Days, 2014
• Mobile devices, to TV, to cars, to gaming, and so much more
3. DroidCon UK 2015
2
• Hosted in Business Design Center London for the 6th year
• Europe’s Largest Android Conference
• Speakers from consumer brands, mobile organizations, mobile
operators and industries touched by the mobile market — including
advertising, banking, health, entertainment and education
• Presented at more than 50 conference sessions
4. Agenda
• Android for Java Developers
• Meaningful Motion
• Mobile Services From Google
• Gradle - Gradle Performance
• Jack and Jill Build System
• RxJava, RxAndroid
• Kotlin Language
5. 4
Android For Java Developers
The lead of the Android UI Toolkit team at Google
Developing for Android: Contents Introduction
I: Understanding the Mobile Context
II: The Rules: Memory
III: The Rules: Performance
IV: The Rules: Networking
V: The Rules: Language & Libraries
VI: The Rules: Storage
VII: The Rules: Framework
VIII: The Rules: User Interface
IX: Tools
https://medium.com/google-developers/developing-for-android-introduction-5345b451567c#.nbwgkioul
6. 4
Android For Java Developers…
Java Programming Language
Runtime
Hardware
Language != Platform
Server - Runtime
Server
Java Programming Language
Dalvik
Server-Land Android
Moving,
compacting
collector
CPU: very
very fast
Memory:
Basically ∞
ART
CPU: wayyyy
slower
Idle
Compaction
No
Compaction
Java Programming Language
11. 4
Android For Java Developers…
Fewer allocations lead to:
• Smaller heap
• Faster allocation times
• Faster collection times
• Fewer pauses
• Less CPU usage
• Happier users!
28. 4
Mobile Services From Google
Tip Two: Use Lite Mode Maps
https://developers.google.com/maps/documentation/android-api/lite?hl=en
29. 4
Mobile Services From Google
Tip Three: Consider GeoJSON or KML
• Standard formats for encoding geo data (GeoJSON) or
outlines KML
• Android Map Utils library includes parsers for these
• Can save you a lot of coding in some scenarios, and
provides an optimized experience
31. 4
Mobile Services From Google
Tip Five: Consider
Polyline Encoding!
• If you collect lots of location data in
order to map a taken route, these
might help!
• Example: Dog walking, Map a
bike ride or hike etc.
32. 4
Mobile Services From Google
Tip Six: Curated Locations
• The Places API is awesome
Don’t just call it blindly
• Consider Curation
Local DB
Backed up with Places
• Be careful of TOS
Don’t cache places
Use their IDs
33. 4
Mobile Services From Google
Tip Seven: Location Sensor Optimisation
• Know when to start and stop listening
• getLastKnownLocation
• if you need a location quickly
• Maintain a best estimate
• Compare update with previous ones and remove bad
data
• Adjust the Fused Location Provider as needed
• Remember, the most sensitive, the higher the cost
34. 4
Mobile Services From Google
Tip Eight: Map Overlays
• Be careful when using overlays
• Good example: trafic
• Bad example: different coloured pins on different
overlays!
• Always give the users to turn them on and off.
35. 4
Mobile Services From Google
Tip Nine: Using Beacons
• Consider Beacon Virtualisation
• Track the Beacon namespace / id in your own DB
• Assign these to real world locations
36. 4
Mobile Services From Google
Tip Ten: API Utility Library
• GeoJSON / KML
• Heatmaps
• Customized Markers
• Clusters
• Polyline Encoding
• Distance, Area, Heading Calculation
• Open Source!
40. 4
Gradle…
Why Gradle?
• Conciseness
• Polyglot
• Multiple teams
• Multiple languages
• Coordinated releases
• Product Delivery
• more than just building APKS
• documentation with tested code examples
• auto-provisioned dev environments
• automated release process
41. 4
Gradle…
• How to force Gradle to rerun the tasks even if they are up
to date? (without clean)
./gradlew build - -rerun-tasks
50. 4
The Jack and Jill Build System
ASSETS ASSETS
XML resources
(.xml)
Compiled
XML resources
(.xml)
Source code
(.java)
Libraries
(.class)
Runtime
(.class)
Java bytecode
(.class)
Libraries
(.class)
Dalvik bytecode
(classes.dex)
Javac Dx
Aapt
Android Build System
Aapt: Android Asset Packaging Tool
51. 4
The Jack and Jill Build System
ASSETS ASSETS
XML resources
(.xml)
Compiled
XML resources
(.xml)
Source code
(.java)
Libraries
(.class)
Runtime
(.class)
Java
bytecode
(.class)
Libraries
(.class)
Dalvik bytecode
(classes.dex)
Javac Dx
Aapt
Proguard
Proguard
Optimized
Java
bytecode
(.class)
ProGuard
config (.txt)
ProGuard
mapping (.txt)
52. 4
The Jack and Jill Build System
ASSETS ASSETS
XML resources
(.xml)
Compiled
XML resources
(.xml)
Source code
(.java)
Libraries
(.class)
Runtime
(.class)
Libraries
(.jayce)
Dalvik bytecode
(classes.dex)
Jack
Aapt
Jack and Jill
ProGuard
config (.txt)
ProGuard
mapping (.txt)
Runtime
(.jayce)
Jill
Jill
53. 4
The Jack and Jill Build System…
How to use Jack using Gradle
Build Tools 21.1.1
Android Stuid 1.0.0+
android {
...
buildToolsRevision ‘21.1.2’
defaultConfig {
// Enable the experimental Jack build tools.
useJack = true
}
...
}
54. 4
The Jack and Jill Build System…
Using command lines
Jack usage:
java -jar <SDK>/build-tools/21.1.1/jack.jar --help
Jill usage:
java -jar <SDK>/build-tools/21.1.1/jill.jar --help
55. 4
The Jack and Jill Build System…
Implications of Jack and Jill
• Java Annotation processors - supported in Jack
E.g. Dagger, Butterknife
• Bytecode processors - only supported via Jill
E.g. JaCoCo, Retrolambda
• Other JVM languages - only supported via Jill
E.g. Scala, Groovy, art
56. 4
The Jack and Jill Build System…
Shrinking and Obfuscation support
"--config-proguard"
Common options:
@
-include
-basedirectory
-injars
-outjars // only 1 output jar supported
-libraryjars
-dontoptimize // required: Jack does not optimize
-dontpreverify // required: Jack does not preverify
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers
-forceprocessing
-keep
-keepclassmembers
-keepclasseswithmembers
-keepnames
-keepclassmembernames
-keepclasseswithmembernames
-printseeds
57. 4
The Jack and Jill Build System…
Shrinking and Obfuscation support
Obfuscation options:
-dontobfuscate
-printmapping
-applymapping
-obfuscationdictionary
-classobfuscationdictionary
-packageobfuscationdictionary
-useuniqueclassmembernames
-dontusemixedcaseclassnames
-keeppackagenames
-flattenpackagehierarchy
-repackageclasses
-keepattributes
-adaptclassstrings
58. 4
The Jack and Jill Build System…
56 sn
11 sn
9 sn
8 sn
32 sn
53 sn
29 sn
2m50sn
1m48sn
20sn
9sn
9sn
11sn
62. 4
RxJava, RxAndroid
ReactiveX
• created by Microsoft
a library for composing asynchronous and event-based
programs by using observable sequences
RxJava
• a Java VM implementation of ReactiveX
• Lightweight
• Polygot Implementation
• Java6+
• JVM-based languages Groovy, Clojure, JRuby, Kotlin,
Scala
• RxJava Libraries : Hystrix, Camel RX, rxjava-http-tail,
mod-rxvertx - Extension for VertX, rxjava-jdbc, rtree
65. 4
RxJava, RxAndroid…
RxAndroid: Reactive Extensions for Android
• adds the minimum classes to RxJava that make writing
reactive components in Android applications easy and
hassle-free.
• provides a Scheduler that schedules on the main UI
thread or any given Handler
70. 4
Kotlin
Kotlin is a statically-typed programming language that runs
on the Java Virtual Machine and also can be compiled to
JavaScript source code. Its primary development is from a
team of JetBrains.
Philosophy
Development lead Andrey Breslav has said that Kotlin is
designed to be an industrial-strength object-oriented
language, and to be a better language than Java but still
be fully interoperable with Java code, allowing companies to
make a gradual migration from Java to Kotlin.