SlideShare a Scribd company logo
Gradle and
Your Android
Wearable
Projects
Copyright © 2014 CommonsWare, LLC
One APK To Rule Them All
●

One APK, regardless of device type

●

Original Android development vision

●

●

Still works for conventional apps... within
reason
Starts to break down as you go beyond
traditional device types into things like
wearables

Copyright © 2014 CommonsWare, LLC
Presentation Terminology
●

Device
●

Runs a mainstream mobile operating system, designed for
multiple form factors
–
–

●

Today: Android, Tizen
Tomorrow: who knows?

Accessory
●

●

●

Runs some dedicated OS
Most/all app logic resides on tethered phone or tablet

Hybrid: dedicated OS, but apps run on wearable

Copyright © 2014 CommonsWare, LLC
Terminology Examples
●

Device
●
●

Omate TrueSmart

●

I'm Watch

●

●

Google Glass

Samsung Gear 2 / Gear 2 Neo

Accessory
●
●

Samsung Gear Fit

●

●

SONY SmartWatch/SW2
Fitbit

Hybrid
●

Pebble

Copyright © 2014 CommonsWare, LLC
Wearables: Why Multiple APKs?
●

CPU architecture

●

Distribution channel (e.g., no Play Services)

●

Per-device libraries
●

Licensing

●

Bulk

●

API level

●

Entry points and security

●

Resources

Copyright © 2014 CommonsWare, LLC
A Specific Wearable Scenario
●

Main App
●

●

SONY SW2
●

●

Phones, tablets, modern Android wearable devices
(Omate TrueSmart)
Dedicated libraries

I'm Watch
●

Workarounds where new API options are missing

Copyright © 2014 CommonsWare, LLC
Other Possible Scenarios
●

Samsung Gear Fit
●

●

Dedicated libraries, dedicated distribution channel

Google Glass
●

●

●

New UI backed by common code
Dedicated distribution channel

Pebble
●

Separate C language project for on-device portion of app

●

Android project for the on-phone tethered side

Copyright © 2014 CommonsWare, LLC
Classic Solution: Library Project
●

Common materials in the library
●

Java code

●

Standard resources

●

Per-device apps that leverage the library

●

Works, but a bit clunky
●

Future: relegated to cases where library needs to
be used by totally disparate apps

Copyright © 2014 CommonsWare, LLC
Gradle Solution: Product Flavors
●

One Project, N Flavors
●

●

Alternative Java classes (one per flavor)

●

●

Additions to manifest
Additional or replacement resources

Each Flavor Generates Own APK
●

●

Unique package name, but independent from your
R classes

Other techniques available as well

Copyright © 2014 CommonsWare, LLC
What Is Gradle?
●

Role: Build Automation
●

●

Implementation: It's Groovy
●

●

Think Ant plus Maven plus other goodness
DSL implemented in Groovy, blending declarative
structures and full-blown scripting

Provider: Gradleware
●

Open source, Apache licensed

Copyright © 2014 CommonsWare, LLC
Gotta Getta Gradle
●

Direct Download

●

The Gradle Wrapper
●

gradlew script and related files in a repo

●

Designed for boostrapping
–
–

●

Running the script does a Gradle build
Running the script installs Gradle itself if development
machine does not have it

Actual Gradle comes from wherever script says
–

Net: only use this if you REALLY trust the source

Copyright © 2014 CommonsWare, LLC
The Basic Gradle Process
●

Write build.gradle File
●

●

Same role as build.xml for Ant, etc.

●

●

Describes sources and results
Usually in root of project directory

Run gradle / gradlew
●

Supply task name as command-line parameter

●

Optional: IDE integration

Copyright © 2014 CommonsWare, LLC
Escape From Eclipse
●

Exporting a build.gradle
●

Export wizard in Eclipse through current ADT

●

Choose project(s) to export

●

Get build.gradle files generated for you
–

●

A bit more complicated than the normal build.gradle
starting point due to legacy project structure

NOTE: Not Kept in Sync!
●

Project changes in Eclipse do not mirror to
build.gradle!

Copyright © 2014 CommonsWare, LLC
build.gradle: High-Level View
●

buildscript {}
●

Describing dependencies for running the build

●

Key: Android plugin

●

apply plugin: 'android'

●

dependencies {}
●

●

Describing compile-time dependencies (JARs, etc.)

android {}
●

Tailoring what Android builds for you

Copyright © 2014 CommonsWare, LLC
Tons o' Tasks
●

assemble*
●

●

●

Compiles APK for you
Tied to “build type” (assembleDebug,
assembleRelease are default)

install*
●

Installs APK on device for you, after assembly

●

Only installDebug works by default
–

installRelease requires configuring your signing
keys

Copyright © 2014 CommonsWare, LLC
Project Structures, Old and New
●

Original Recipe
●

●

●

src/, res/, assets/ in top-level project directory
libs/ also in top-level project directory

New Project Structure
●

src/, res/, assets/ in subdirectory
–
–

●

main/ by default
Others by “build type” or “product flavor”

libs/ remains in top-level directory
–

Or gone, replaced by artifacts

Copyright © 2014 CommonsWare, LLC
Pieces of New Project Structure
●

Source Sets

●

Build Types

●

Product Flavors

●

Build Variants

Copyright © 2014 CommonsWare, LLC
Source Sets
●

Gradle Construct for Organizing “Source”
●

●

In Android's case, includes resources and assets

Vision
●

●

Have one main/ source set with most of your code
Have alternatives in other source sets, used
conditionally
–

Resources, assets: can replace main/ source set

–

Java: cannot replace main/, can only add

Copyright © 2014 CommonsWare, LLC
Build Types
●

Android Plugin Construct for Describing
Output Variations
●

●

Two build types come default: debug and
release

Build Types Configurable
●

●

●

Project properties in build.gradle
Source sets

Define Others As Needed
●

Smoke tests, debuggable-release builds, etc.

Copyright © 2014 CommonsWare, LLC
Product Flavors and Build Variants
●

Product Flavors
●

●

●

Android plugin construct for different deployment
variations
None defined by default, can create your own

Build Variants
●

●

Cross product of build types and product flavors
Drive task names (assembleSonyDebug) and
results

Copyright © 2014 CommonsWare, LLC
Quick Dependencies Overview
●

Sub-Projects

●

JARs
●

●

AARs
●

●

compile fileTree(), sub-projects, or replace
with artifacts
Compiled Android library projects

Artifacts
●

Maven Central and/or your own repositories

●

JARs and AARs supported

Copyright © 2014 CommonsWare, LLC
Specific Scenario Build Script
●

One Project

●

Three Product Flavors
●

standard

●

sony

●

imwatch

Copyright © 2014 CommonsWare, LLC
Flavor-Specific Changes
●

SONY
●

sonyCompile

●

Hand-rolled local artifacts for SONY libraries
–

●

Long-term: hope they publish to Maven Central or own
artifact repository

I'm Watch
●

Resources

Copyright © 2014 CommonsWare, LLC
What You Get
●

Three APKs
●

●

●

Two for Play Store distribution (standard and
SONY)
One for dedicated distribution (I'm Watch)

In general, one APK per build variant
●

For release = one APK per product flavor

Copyright © 2014 CommonsWare, LLC
Gradle Pros...
●

One build system to rule them all
●

●

...in the fullness of time

Much more powerful than Ant for
command-line builds

●

More flexible options for code reuse

●

Richer build script syntax

Copyright © 2014 CommonsWare, LLC
...and Cons
●

Android Studio still a work in progress

●

No Eclipse support yet

●

Gradle for Android still has its own bugs and
limitations

●

Breaking changes with updates

●

AAR packaging far from universal
●

...let alone being artifacts for easy consumption

Copyright © 2014 CommonsWare, LLC
Where To Learn More
●

http://tools.android.com/
●

Home of the Android tools team

●

Information on Gradle for Android, Android Studio
–

●

http://gradle.org
●

●

For general Gradle information

http://gradleware.com
●

●

Note: much is out of date!

Firm behind Gradle's development, offering training and consulting

http://commonsware.com/Android
●

Some book by some balding guy

●

Several chapters on Gradle for Android

Copyright © 2014 CommonsWare, LLC

More Related Content

What's hot

Embedded Android Workshop with Pie
Embedded Android Workshop with PieEmbedded Android Workshop with Pie
Embedded Android Workshop with Pie
Opersys inc.
 
Targeting Android with Qt
Targeting Android with QtTargeting Android with Qt
Targeting Android with Qt
Espen Riskedal
 
Effective Spring on Kubernetes
Effective Spring on KubernetesEffective Spring on Kubernetes
Effective Spring on Kubernetes
Neven Cvetković
 
Google I/O 2019 - what's new in Android Q and Jetpack
Google I/O 2019 - what's new in Android Q and JetpackGoogle I/O 2019 - what's new in Android Q and Jetpack
Google I/O 2019 - what's new in Android Q and Jetpack
Sunita Singh
 
The unconventional devices for the video streaming in Android
The unconventional devices for the video streaming in AndroidThe unconventional devices for the video streaming in Android
The unconventional devices for the video streaming in Android
Alessandro Martellucci
 
Embedded Android Workshop with Marshmallow
Embedded Android Workshop with MarshmallowEmbedded Android Workshop with Marshmallow
Embedded Android Workshop with Marshmallow
Opersys inc.
 
Developer Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for BeginnersDeveloper Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for Beginners
Jiaxuan Lin
 
IPhone Web Development With Grails from CodeMash 2009
IPhone Web Development With Grails from CodeMash 2009IPhone Web Development With Grails from CodeMash 2009
IPhone Web Development With Grails from CodeMash 2009
Christopher Judd
 
Introduce Android TV and new features from Google I/O 2016
Introduce Android TV and new features from Google I/O 2016Introduce Android TV and new features from Google I/O 2016
Introduce Android TV and new features from Google I/O 2016
GDG Korea
 
Rapid and Reliable Developing with HTML5 & GWT
Rapid and Reliable Developing with HTML5 & GWTRapid and Reliable Developing with HTML5 & GWT
Rapid and Reliable Developing with HTML5 & GWT
Manuel Carrasco Moñino
 
Embedded Android Workshop with Lollipop
Embedded Android Workshop with LollipopEmbedded Android Workshop with Lollipop
Embedded Android Workshop with Lollipop
Opersys inc.
 
Flutter not yet another mobile cross-platform framework - i ox-kl19
Flutter   not yet another mobile cross-platform framework - i ox-kl19Flutter   not yet another mobile cross-platform framework - i ox-kl19
Flutter not yet another mobile cross-platform framework - i ox-kl19
oradoe
 
Mobile development with Flutter
Mobile development with FlutterMobile development with Flutter
Mobile development with Flutter
Awok
 
Chrome Dev Summit Highlights (NYC GDG Dec 2013)
Chrome Dev Summit Highlights (NYC GDG Dec 2013)Chrome Dev Summit Highlights (NYC GDG Dec 2013)
Chrome Dev Summit Highlights (NYC GDG Dec 2013)
Nitya Narasimhan
 
UI Automation Using Flutter
UI Automation Using FlutterUI Automation Using Flutter
UI Automation Using Flutter
Sharaniya Premkumar
 
Flutter101
Flutter101Flutter101
Flutter101
인수 장
 
[Android] DI in multimodule application
[Android] DI in multimodule application[Android] DI in multimodule application
[Android] DI in multimodule application
Oleg Mazhukin
 
Web and Native in 2012
Web and Native in 2012Web and Native in 2012
Web and Native in 2012
jhugman
 
Mastering the NDK with Android Studio 2.0 and the gradle-experimental plugin
Mastering the NDK with Android Studio 2.0 and the gradle-experimental pluginMastering the NDK with Android Studio 2.0 and the gradle-experimental plugin
Mastering the NDK with Android Studio 2.0 and the gradle-experimental plugin
Xavier Hallade
 
JHipster for Spring Boot webinar
JHipster for Spring Boot webinarJHipster for Spring Boot webinar
JHipster for Spring Boot webinarJulien Dubois
 

What's hot (20)

Embedded Android Workshop with Pie
Embedded Android Workshop with PieEmbedded Android Workshop with Pie
Embedded Android Workshop with Pie
 
Targeting Android with Qt
Targeting Android with QtTargeting Android with Qt
Targeting Android with Qt
 
Effective Spring on Kubernetes
Effective Spring on KubernetesEffective Spring on Kubernetes
Effective Spring on Kubernetes
 
Google I/O 2019 - what's new in Android Q and Jetpack
Google I/O 2019 - what's new in Android Q and JetpackGoogle I/O 2019 - what's new in Android Q and Jetpack
Google I/O 2019 - what's new in Android Q and Jetpack
 
The unconventional devices for the video streaming in Android
The unconventional devices for the video streaming in AndroidThe unconventional devices for the video streaming in Android
The unconventional devices for the video streaming in Android
 
Embedded Android Workshop with Marshmallow
Embedded Android Workshop with MarshmallowEmbedded Android Workshop with Marshmallow
Embedded Android Workshop with Marshmallow
 
Developer Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for BeginnersDeveloper Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for Beginners
 
IPhone Web Development With Grails from CodeMash 2009
IPhone Web Development With Grails from CodeMash 2009IPhone Web Development With Grails from CodeMash 2009
IPhone Web Development With Grails from CodeMash 2009
 
Introduce Android TV and new features from Google I/O 2016
Introduce Android TV and new features from Google I/O 2016Introduce Android TV and new features from Google I/O 2016
Introduce Android TV and new features from Google I/O 2016
 
Rapid and Reliable Developing with HTML5 & GWT
Rapid and Reliable Developing with HTML5 & GWTRapid and Reliable Developing with HTML5 & GWT
Rapid and Reliable Developing with HTML5 & GWT
 
Embedded Android Workshop with Lollipop
Embedded Android Workshop with LollipopEmbedded Android Workshop with Lollipop
Embedded Android Workshop with Lollipop
 
Flutter not yet another mobile cross-platform framework - i ox-kl19
Flutter   not yet another mobile cross-platform framework - i ox-kl19Flutter   not yet another mobile cross-platform framework - i ox-kl19
Flutter not yet another mobile cross-platform framework - i ox-kl19
 
Mobile development with Flutter
Mobile development with FlutterMobile development with Flutter
Mobile development with Flutter
 
Chrome Dev Summit Highlights (NYC GDG Dec 2013)
Chrome Dev Summit Highlights (NYC GDG Dec 2013)Chrome Dev Summit Highlights (NYC GDG Dec 2013)
Chrome Dev Summit Highlights (NYC GDG Dec 2013)
 
UI Automation Using Flutter
UI Automation Using FlutterUI Automation Using Flutter
UI Automation Using Flutter
 
Flutter101
Flutter101Flutter101
Flutter101
 
[Android] DI in multimodule application
[Android] DI in multimodule application[Android] DI in multimodule application
[Android] DI in multimodule application
 
Web and Native in 2012
Web and Native in 2012Web and Native in 2012
Web and Native in 2012
 
Mastering the NDK with Android Studio 2.0 and the gradle-experimental plugin
Mastering the NDK with Android Studio 2.0 and the gradle-experimental pluginMastering the NDK with Android Studio 2.0 and the gradle-experimental plugin
Mastering the NDK with Android Studio 2.0 and the gradle-experimental plugin
 
JHipster for Spring Boot webinar
JHipster for Spring Boot webinarJHipster for Spring Boot webinar
JHipster for Spring Boot webinar
 

Similar to Gradle and Your Android Wearable Projects

LinkedIn's Consistent Android Testing Environments Using Gradle
LinkedIn's Consistent Android Testing Environments Using GradleLinkedIn's Consistent Android Testing Environments Using Gradle
LinkedIn's Consistent Android Testing Environments Using Gradle
Drew Hannay
 
Google ART (Android RunTime)
Google ART (Android RunTime)Google ART (Android RunTime)
Google ART (Android RunTime)
Niraj Solanke
 
Build your android app with gradle
Build your android app with gradleBuild your android app with gradle
Build your android app with gradle
Swain Loda
 
Apache Maven
Apache MavenApache Maven
Apache Maven
Rahul Tanwani
 
Open Source Jumpstart Tooling Up Intro
Open Source Jumpstart Tooling Up IntroOpen Source Jumpstart Tooling Up Intro
Open Source Jumpstart Tooling Up Intro
Skills Matter
 
Embedded Android Workshop with Marshmallow
Embedded Android Workshop with MarshmallowEmbedded Android Workshop with Marshmallow
Embedded Android Workshop with Marshmallow
Opersys inc.
 
Embedded Android Workshop with Lollipop
Embedded Android Workshop with LollipopEmbedded Android Workshop with Lollipop
Embedded Android Workshop with Lollipop
Opersys inc.
 
Continuous integration for androids
Continuous integration for androidsContinuous integration for androids
Continuous integration for androidsKirill Zotin
 
Voxxed days Vilnius 2015 - Android Reverse Engineering Lab
Voxxed days Vilnius 2015 - Android Reverse Engineering LabVoxxed days Vilnius 2015 - Android Reverse Engineering Lab
Voxxed days Vilnius 2015 - Android Reverse Engineering Lab
Ron Munitz
 
Android Application Development
Android Application DevelopmentAndroid Application Development
Android Application Development
Khaleel Jageer
 
Intoduction to Android Development
Intoduction to Android DevelopmentIntoduction to Android Development
Intoduction to Android Development
Ben Hardill
 
ENIB 2015-2016 - CAI Web - S01E01- La forge JavaScript
ENIB 2015-2016 - CAI Web - S01E01- La forge JavaScriptENIB 2015-2016 - CAI Web - S01E01- La forge JavaScript
ENIB 2015-2016 - CAI Web - S01E01- La forge JavaScript
Horacio Gonzalez
 
Droidcon uk2012 androvm
Droidcon uk2012 androvmDroidcon uk2012 androvm
Droidcon uk2012 androvm
dfages
 
Embedded Android Workshop with Nougat
Embedded Android Workshop with NougatEmbedded Android Workshop with Nougat
Embedded Android Workshop with Nougat
Opersys inc.
 
Mobile UI Testing using Appium and Docker
Mobile UI Testing using Appium and DockerMobile UI Testing using Appium and Docker
Mobile UI Testing using Appium and Docker
Moataz Nabil
 
Embedded Android Workshop with Marshmallow
Embedded Android Workshop with MarshmallowEmbedded Android Workshop with Marshmallow
Embedded Android Workshop with Marshmallow
Karim Yaghmour
 
Embedded Android Workshop with Marshmallow
Embedded Android Workshop with MarshmallowEmbedded Android Workshop with Marshmallow
Embedded Android Workshop with Marshmallow
Opersys inc.
 
Apigee deploy grunt plugin.1.0
Apigee deploy grunt plugin.1.0Apigee deploy grunt plugin.1.0
Apigee deploy grunt plugin.1.0
Diego Zuluaga
 

Similar to Gradle and Your Android Wearable Projects (20)

LinkedIn's Consistent Android Testing Environments Using Gradle
LinkedIn's Consistent Android Testing Environments Using GradleLinkedIn's Consistent Android Testing Environments Using Gradle
LinkedIn's Consistent Android Testing Environments Using Gradle
 
Google ART (Android RunTime)
Google ART (Android RunTime)Google ART (Android RunTime)
Google ART (Android RunTime)
 
Android Development Tutorial V3
Android Development Tutorial   V3Android Development Tutorial   V3
Android Development Tutorial V3
 
Build your android app with gradle
Build your android app with gradleBuild your android app with gradle
Build your android app with gradle
 
Apache Maven
Apache MavenApache Maven
Apache Maven
 
Open Source Jumpstart Tooling Up Intro
Open Source Jumpstart Tooling Up IntroOpen Source Jumpstart Tooling Up Intro
Open Source Jumpstart Tooling Up Intro
 
Embedded Android Workshop with Marshmallow
Embedded Android Workshop with MarshmallowEmbedded Android Workshop with Marshmallow
Embedded Android Workshop with Marshmallow
 
Embedded Android Workshop with Lollipop
Embedded Android Workshop with LollipopEmbedded Android Workshop with Lollipop
Embedded Android Workshop with Lollipop
 
Continuous integration for androids
Continuous integration for androidsContinuous integration for androids
Continuous integration for androids
 
Voxxed days Vilnius 2015 - Android Reverse Engineering Lab
Voxxed days Vilnius 2015 - Android Reverse Engineering LabVoxxed days Vilnius 2015 - Android Reverse Engineering Lab
Voxxed days Vilnius 2015 - Android Reverse Engineering Lab
 
Android Application Development
Android Application DevelopmentAndroid Application Development
Android Application Development
 
Intoduction to Android Development
Intoduction to Android DevelopmentIntoduction to Android Development
Intoduction to Android Development
 
ENIB 2015-2016 - CAI Web - S01E01- La forge JavaScript
ENIB 2015-2016 - CAI Web - S01E01- La forge JavaScriptENIB 2015-2016 - CAI Web - S01E01- La forge JavaScript
ENIB 2015-2016 - CAI Web - S01E01- La forge JavaScript
 
Droidcon uk2012 androvm
Droidcon uk2012 androvmDroidcon uk2012 androvm
Droidcon uk2012 androvm
 
Embedded Android Workshop with Nougat
Embedded Android Workshop with NougatEmbedded Android Workshop with Nougat
Embedded Android Workshop with Nougat
 
Mobile UI Testing using Appium and Docker
Mobile UI Testing using Appium and DockerMobile UI Testing using Appium and Docker
Mobile UI Testing using Appium and Docker
 
Embedded Android Workshop with Marshmallow
Embedded Android Workshop with MarshmallowEmbedded Android Workshop with Marshmallow
Embedded Android Workshop with Marshmallow
 
Embedded Android Workshop with Marshmallow
Embedded Android Workshop with MarshmallowEmbedded Android Workshop with Marshmallow
Embedded Android Workshop with Marshmallow
 
Apigee deploy grunt plugin.1.0
Apigee deploy grunt plugin.1.0Apigee deploy grunt plugin.1.0
Apigee deploy grunt plugin.1.0
 
Android NDK
Android NDKAndroid NDK
Android NDK
 

More from CommonsWare

The Action Bar: Front to Back
The Action Bar: Front to BackThe Action Bar: Front to Back
The Action Bar: Front to Back
CommonsWare
 
Secondary Screen Support Using DisplayManager
Secondary Screen Support Using DisplayManagerSecondary Screen Support Using DisplayManager
Secondary Screen Support Using DisplayManager
CommonsWare
 
Mastering the Master Detail Pattern
Mastering the Master Detail PatternMastering the Master Detail Pattern
Mastering the Master Detail Pattern
CommonsWare
 
Not Quite As Painful Threading
Not Quite As Painful ThreadingNot Quite As Painful Threading
Not Quite As Painful Threading
CommonsWare
 
Android Development: The 20,000-Foot View
Android Development: The 20,000-Foot ViewAndroid Development: The 20,000-Foot View
Android Development: The 20,000-Foot View
CommonsWare
 
Maps V2... And You!
Maps V2... And You!Maps V2... And You!
Maps V2... And You!
CommonsWare
 
A Deep Dive Into ViewPager
A Deep Dive Into ViewPagerA Deep Dive Into ViewPager
A Deep Dive Into ViewPager
CommonsWare
 
Second-Screen Support in Android 4.2
Second-Screen Support in Android 4.2Second-Screen Support in Android 4.2
Second-Screen Support in Android 4.2
CommonsWare
 
Integrate Android Apps and Web Apps
Integrate Android Apps and Web AppsIntegrate Android Apps and Web Apps
Integrate Android Apps and Web Apps
CommonsWare
 
From Android to the Mobile Web
From Android to the Mobile WebFrom Android to the Mobile Web
From Android to the Mobile Web
CommonsWare
 
X Means Y
X Means YX Means Y
X Means Y
CommonsWare
 
The Wonderful World of Wearables
The Wonderful World of WearablesThe Wonderful World of Wearables
The Wonderful World of Wearables
CommonsWare
 
Securing User Data with SQLCipher
Securing User Data with SQLCipherSecuring User Data with SQLCipher
Securing User Data with SQLCipher
CommonsWare
 
Beaming Data to Devices with NFC
Beaming Data to Devices with NFCBeaming Data to Devices with NFC
Beaming Data to Devices with NFC
CommonsWare
 
What's New in Jelly Bean
What's New in Jelly BeanWhat's New in Jelly Bean
What's New in Jelly Bean
CommonsWare
 
Making Money at Mobile: 60 Business Models
Making Money at Mobile: 60 Business ModelsMaking Money at Mobile: 60 Business Models
Making Money at Mobile: 60 Business Models
CommonsWare
 
AppsWorld Keynote
AppsWorld KeynoteAppsWorld Keynote
AppsWorld Keynote
CommonsWare
 
Android Hardware That's A Little Bit... Odd
Android Hardware That's A Little Bit... OddAndroid Hardware That's A Little Bit... Odd
Android Hardware That's A Little Bit... Odd
CommonsWare
 
If I Were Starting Now
If I Were Starting NowIf I Were Starting Now
If I Were Starting Now
CommonsWare
 
Tuning Android Applications (Part Deux)
Tuning Android Applications (Part Deux)Tuning Android Applications (Part Deux)
Tuning Android Applications (Part Deux)
CommonsWare
 

More from CommonsWare (20)

The Action Bar: Front to Back
The Action Bar: Front to BackThe Action Bar: Front to Back
The Action Bar: Front to Back
 
Secondary Screen Support Using DisplayManager
Secondary Screen Support Using DisplayManagerSecondary Screen Support Using DisplayManager
Secondary Screen Support Using DisplayManager
 
Mastering the Master Detail Pattern
Mastering the Master Detail PatternMastering the Master Detail Pattern
Mastering the Master Detail Pattern
 
Not Quite As Painful Threading
Not Quite As Painful ThreadingNot Quite As Painful Threading
Not Quite As Painful Threading
 
Android Development: The 20,000-Foot View
Android Development: The 20,000-Foot ViewAndroid Development: The 20,000-Foot View
Android Development: The 20,000-Foot View
 
Maps V2... And You!
Maps V2... And You!Maps V2... And You!
Maps V2... And You!
 
A Deep Dive Into ViewPager
A Deep Dive Into ViewPagerA Deep Dive Into ViewPager
A Deep Dive Into ViewPager
 
Second-Screen Support in Android 4.2
Second-Screen Support in Android 4.2Second-Screen Support in Android 4.2
Second-Screen Support in Android 4.2
 
Integrate Android Apps and Web Apps
Integrate Android Apps and Web AppsIntegrate Android Apps and Web Apps
Integrate Android Apps and Web Apps
 
From Android to the Mobile Web
From Android to the Mobile WebFrom Android to the Mobile Web
From Android to the Mobile Web
 
X Means Y
X Means YX Means Y
X Means Y
 
The Wonderful World of Wearables
The Wonderful World of WearablesThe Wonderful World of Wearables
The Wonderful World of Wearables
 
Securing User Data with SQLCipher
Securing User Data with SQLCipherSecuring User Data with SQLCipher
Securing User Data with SQLCipher
 
Beaming Data to Devices with NFC
Beaming Data to Devices with NFCBeaming Data to Devices with NFC
Beaming Data to Devices with NFC
 
What's New in Jelly Bean
What's New in Jelly BeanWhat's New in Jelly Bean
What's New in Jelly Bean
 
Making Money at Mobile: 60 Business Models
Making Money at Mobile: 60 Business ModelsMaking Money at Mobile: 60 Business Models
Making Money at Mobile: 60 Business Models
 
AppsWorld Keynote
AppsWorld KeynoteAppsWorld Keynote
AppsWorld Keynote
 
Android Hardware That's A Little Bit... Odd
Android Hardware That's A Little Bit... OddAndroid Hardware That's A Little Bit... Odd
Android Hardware That's A Little Bit... Odd
 
If I Were Starting Now
If I Were Starting NowIf I Were Starting Now
If I Were Starting Now
 
Tuning Android Applications (Part Deux)
Tuning Android Applications (Part Deux)Tuning Android Applications (Part Deux)
Tuning Android Applications (Part Deux)
 

Recently uploaded

From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 

Recently uploaded (20)

From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 

Gradle and Your Android Wearable Projects

  • 2. One APK To Rule Them All ● One APK, regardless of device type ● Original Android development vision ● ● Still works for conventional apps... within reason Starts to break down as you go beyond traditional device types into things like wearables Copyright © 2014 CommonsWare, LLC
  • 3. Presentation Terminology ● Device ● Runs a mainstream mobile operating system, designed for multiple form factors – – ● Today: Android, Tizen Tomorrow: who knows? Accessory ● ● ● Runs some dedicated OS Most/all app logic resides on tethered phone or tablet Hybrid: dedicated OS, but apps run on wearable Copyright © 2014 CommonsWare, LLC
  • 4. Terminology Examples ● Device ● ● Omate TrueSmart ● I'm Watch ● ● Google Glass Samsung Gear 2 / Gear 2 Neo Accessory ● ● Samsung Gear Fit ● ● SONY SmartWatch/SW2 Fitbit Hybrid ● Pebble Copyright © 2014 CommonsWare, LLC
  • 5. Wearables: Why Multiple APKs? ● CPU architecture ● Distribution channel (e.g., no Play Services) ● Per-device libraries ● Licensing ● Bulk ● API level ● Entry points and security ● Resources Copyright © 2014 CommonsWare, LLC
  • 6. A Specific Wearable Scenario ● Main App ● ● SONY SW2 ● ● Phones, tablets, modern Android wearable devices (Omate TrueSmart) Dedicated libraries I'm Watch ● Workarounds where new API options are missing Copyright © 2014 CommonsWare, LLC
  • 7. Other Possible Scenarios ● Samsung Gear Fit ● ● Dedicated libraries, dedicated distribution channel Google Glass ● ● ● New UI backed by common code Dedicated distribution channel Pebble ● Separate C language project for on-device portion of app ● Android project for the on-phone tethered side Copyright © 2014 CommonsWare, LLC
  • 8. Classic Solution: Library Project ● Common materials in the library ● Java code ● Standard resources ● Per-device apps that leverage the library ● Works, but a bit clunky ● Future: relegated to cases where library needs to be used by totally disparate apps Copyright © 2014 CommonsWare, LLC
  • 9. Gradle Solution: Product Flavors ● One Project, N Flavors ● ● Alternative Java classes (one per flavor) ● ● Additions to manifest Additional or replacement resources Each Flavor Generates Own APK ● ● Unique package name, but independent from your R classes Other techniques available as well Copyright © 2014 CommonsWare, LLC
  • 10. What Is Gradle? ● Role: Build Automation ● ● Implementation: It's Groovy ● ● Think Ant plus Maven plus other goodness DSL implemented in Groovy, blending declarative structures and full-blown scripting Provider: Gradleware ● Open source, Apache licensed Copyright © 2014 CommonsWare, LLC
  • 11. Gotta Getta Gradle ● Direct Download ● The Gradle Wrapper ● gradlew script and related files in a repo ● Designed for boostrapping – – ● Running the script does a Gradle build Running the script installs Gradle itself if development machine does not have it Actual Gradle comes from wherever script says – Net: only use this if you REALLY trust the source Copyright © 2014 CommonsWare, LLC
  • 12. The Basic Gradle Process ● Write build.gradle File ● ● Same role as build.xml for Ant, etc. ● ● Describes sources and results Usually in root of project directory Run gradle / gradlew ● Supply task name as command-line parameter ● Optional: IDE integration Copyright © 2014 CommonsWare, LLC
  • 13. Escape From Eclipse ● Exporting a build.gradle ● Export wizard in Eclipse through current ADT ● Choose project(s) to export ● Get build.gradle files generated for you – ● A bit more complicated than the normal build.gradle starting point due to legacy project structure NOTE: Not Kept in Sync! ● Project changes in Eclipse do not mirror to build.gradle! Copyright © 2014 CommonsWare, LLC
  • 14. build.gradle: High-Level View ● buildscript {} ● Describing dependencies for running the build ● Key: Android plugin ● apply plugin: 'android' ● dependencies {} ● ● Describing compile-time dependencies (JARs, etc.) android {} ● Tailoring what Android builds for you Copyright © 2014 CommonsWare, LLC
  • 15. Tons o' Tasks ● assemble* ● ● ● Compiles APK for you Tied to “build type” (assembleDebug, assembleRelease are default) install* ● Installs APK on device for you, after assembly ● Only installDebug works by default – installRelease requires configuring your signing keys Copyright © 2014 CommonsWare, LLC
  • 16. Project Structures, Old and New ● Original Recipe ● ● ● src/, res/, assets/ in top-level project directory libs/ also in top-level project directory New Project Structure ● src/, res/, assets/ in subdirectory – – ● main/ by default Others by “build type” or “product flavor” libs/ remains in top-level directory – Or gone, replaced by artifacts Copyright © 2014 CommonsWare, LLC
  • 17. Pieces of New Project Structure ● Source Sets ● Build Types ● Product Flavors ● Build Variants Copyright © 2014 CommonsWare, LLC
  • 18. Source Sets ● Gradle Construct for Organizing “Source” ● ● In Android's case, includes resources and assets Vision ● ● Have one main/ source set with most of your code Have alternatives in other source sets, used conditionally – Resources, assets: can replace main/ source set – Java: cannot replace main/, can only add Copyright © 2014 CommonsWare, LLC
  • 19. Build Types ● Android Plugin Construct for Describing Output Variations ● ● Two build types come default: debug and release Build Types Configurable ● ● ● Project properties in build.gradle Source sets Define Others As Needed ● Smoke tests, debuggable-release builds, etc. Copyright © 2014 CommonsWare, LLC
  • 20. Product Flavors and Build Variants ● Product Flavors ● ● ● Android plugin construct for different deployment variations None defined by default, can create your own Build Variants ● ● Cross product of build types and product flavors Drive task names (assembleSonyDebug) and results Copyright © 2014 CommonsWare, LLC
  • 21. Quick Dependencies Overview ● Sub-Projects ● JARs ● ● AARs ● ● compile fileTree(), sub-projects, or replace with artifacts Compiled Android library projects Artifacts ● Maven Central and/or your own repositories ● JARs and AARs supported Copyright © 2014 CommonsWare, LLC
  • 22. Specific Scenario Build Script ● One Project ● Three Product Flavors ● standard ● sony ● imwatch Copyright © 2014 CommonsWare, LLC
  • 23. Flavor-Specific Changes ● SONY ● sonyCompile ● Hand-rolled local artifacts for SONY libraries – ● Long-term: hope they publish to Maven Central or own artifact repository I'm Watch ● Resources Copyright © 2014 CommonsWare, LLC
  • 24. What You Get ● Three APKs ● ● ● Two for Play Store distribution (standard and SONY) One for dedicated distribution (I'm Watch) In general, one APK per build variant ● For release = one APK per product flavor Copyright © 2014 CommonsWare, LLC
  • 25. Gradle Pros... ● One build system to rule them all ● ● ...in the fullness of time Much more powerful than Ant for command-line builds ● More flexible options for code reuse ● Richer build script syntax Copyright © 2014 CommonsWare, LLC
  • 26. ...and Cons ● Android Studio still a work in progress ● No Eclipse support yet ● Gradle for Android still has its own bugs and limitations ● Breaking changes with updates ● AAR packaging far from universal ● ...let alone being artifacts for easy consumption Copyright © 2014 CommonsWare, LLC
  • 27. Where To Learn More ● http://tools.android.com/ ● Home of the Android tools team ● Information on Gradle for Android, Android Studio – ● http://gradle.org ● ● For general Gradle information http://gradleware.com ● ● Note: much is out of date! Firm behind Gradle's development, offering training and consulting http://commonsware.com/Android ● Some book by some balding guy ● Several chapters on Gradle for Android Copyright © 2014 CommonsWare, LLC