2. Android Studio 3.0 Introduction
• Introduced at Google I/O 2017
• Improvements:
• Faster Gradle build times
• Profiling tools
• UI
• Network Request Inspection (with Retrofit & OkHTTP)
• Device File Explorer
• App-Private files too! (no more adb run-as!)
• Android Gradle Plugin Improvements
3. Application Structure and Dependencies
• Applications in Android Studio
can be structured into modules
• Drivewyze Example:
• Agatha (Mobile app)
• Gaby (Stripped down for Android
ELDs)
• Erica (Stripped down for even
older Android ELDs)
• Common
• “Magic Sauce”
Agatha Erica Gaby
Common
4. Why have variants?
• Production
• Signing Keys, Production
Environment
• QA
• Unsigned, QA test environment
• Development
• Unsigned, Local-host server
Agatha Erica Gaby
Common
5. Set Theory and the Cross Product
• {A, B, C}
• {A, B, C} ⋈ {D, E, F} =
• AD, AE, AF
• BD, BE, BF
• CD, CE, CF
• {A, B, C} ⋈ {D, E, F} ⋈ {Y, Z} =
• ADY, AEY, AFY
• BDY, BEY, BFY
• CDY, CEY, CFY
• ADZ, AEZ, AFZ
• BDZ, BEZ BFZ
• CDZ, CEZ, CFZ
6. Abstract Real
• “Build type”:
• {Debug, Release, Simulated
Location}
• “Authorization Service / Server
Environment”:
• {Production, QA, Local}
• “Event cache”:
• {Production, QA, Local}
7. Product Flavors & Build Types & Build Variants
• Build Types
• Sets up various build properties.
• The debug build type enables debug options and signs
the APK with the debug key.
• The release build type may shrink, obfuscate, and sign
your APK with a release key for distribution.
• Android Studio creates the debug and release build
types by default.
• Product Flavors
• Product flavors represent different versions of your app
that you may release to users
• Free and paid versions of your app.
• You can customize product flavors to use different code
and resources, while sharing and reusing the parts that
are common to all versions of your app.
• Product flavors are optional and you must create them
manually.
• More info:
• https://developer.android.com/studio/build/index.html
• Build Variants
• The resulting entries in the set formed by cross-product
of BuildTypes x ProductFlavors
freeFlavor paidFlavor
debug freeDebug paidDebug
release freeRelease paidRelease
8. The Old Way
• “Build Type” did not propagate
to dependent modules
• Really old bug in Gradle
• Reported March, 2013
• https://issuetracker.google.com/issu
es/36967265
• “DESCRIPTION:
Gradle plugin does not propagate
whether you are doing a debug
build or a release build to a
dependent android library”
Agatha Build.conf:
buildTypes {
release {…}
debug {…}
simloc {…}
}
productFlavors {
prodFlavor {…}
qaFlavor {…}
devFlavor {…}
}
Dependencies{ …
simlocCompile project(path: ':common', configuration: 'simlocMongoQa')
debugCompile project(path: ':common', configuration: 'libraryMongoQa')
releaseCompile project(path: ':common', configuration: 'libraryMongoProd')}
Common Build.conf:
buildTypes {
mongoDev { … }
mongoQa { … }
mongoProd { … }
}
productFlavors {
library {
buildConfigField 'boolean', 'SIMLOC_BUILD', "false"
}
simloc {
buildConfigField 'boolean', 'SIMLOC_BUILD', "true"
}
}