Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Migrating to Android Studio 3.0

Migrating to Android Studio 3.0

Slides from my talk at Dutch Android User Group in July 2017

I also have a blogpost explaining the api vs implementation dependency: https://jeroenmols.com/blog/2017/06/14/androidstudio3/

Jeroen Mols

July 06, 2017
Tweet

More Decks by Jeroen Mols

Other Decks in Programming

Transcript

  1. @MOLSJEROEN CONTENTS ▸ Dependency configurations ▸ Google Maven repository ▸

    Build variants in modules ▸ Android Studio 3.0 features
  2. @MOLSJEROEN CONTENTS ▸ Dependency configurations ▸ Google Maven repository ▸

    Build variants in modules ▸ Android Studio 3.0 features
  3. @MOLSJEROEN dependencies {
 
 compile 'com.jeroenmols:moduleB:1.0.0'
 } ▸ Code change

    1. Implementation change: internal to module 2. ABI change: exposed to consumers, api change OLD DEPENDENCY CONFIGURATIONS
  4. @MOLSJEROEN dependencies {
 
 compile ‘com.jeroenmols:myawesomelibrary:1.0.0’ // only recompile this

    module
 implementation ‘com.jeroenmols:myawesomelibrary:1.0.0’ // recompile this module and all modules using this one
 api ‘com.jeroenmols:myawesomelibrary:1.0.0’
 } NEW DEPENDENCY CONFIGURATIONS
  5. @MOLSJEROEN dependencies {
 
 compile ‘com.jeroenmols:myawesomelibrary:1.0.0’ // only recompile this

    module
 implementation ‘com.jeroenmols:myawesomelibrary:1.0.0’ // recompile this module and all modules using this one
 api ‘com.jeroenmols:myawesomelibrary:1.0.0’
 } NEW DEPENDENCY CONFIGURATIONS
  6. @MOLSJEROEN dependencies {
 
 compile ‘com.jeroenmols:myawesomelibrary:1.0.0’ // only recompile this

    module
 implementation ‘com.jeroenmols:myawesomelibrary:1.0.0’ // recompile this module and all modules using this one
 api ‘com.jeroenmols:myawesomelibrary:1.0.0’
 } NEW DEPENDENCY CONFIGURATIONS
  7. @MOLSJEROEN MIGRATE DEPENDENCY CONFIGURATIONS ▸ Replace all compile with implementation

    ▸ Use api where you leak a module’s interface ▸ Replace provided configuration with compileOnly ▸ Replace apk configuration with runtimeOnly ▸ Other variants: debugApi, testImplementation
  8. @MOLSJEROEN CONTENTS ▸ Dependency configurations ▸ Google Maven repository ▸

    Build variants in modules ▸ Android Studio 3.0 features
  9. @MOLSJEROEN MAVEN REPOSITORY buildscript {
 ...
 
 dependencies {
 maven

    { url 'https://maven.google.com' }
 }
 }
 
 allprojects {
 repositories {
 maven { url 'https://maven.google.com' }
 }
 }
  10. @MOLSJEROEN MAVEN REPOSITORY buildscript {
 ...
 
 dependencies {
 maven

    { url 'https://maven.google.com' }
 }
 }
 
 allprojects {
 repositories {
 maven { url 'https://maven.google.com' }
 }
 }
  11. @MOLSJEROEN MAVEN REPOSITORY buildscript {
 ...
 
 dependencies {
 maven

    { url 'https://maven.google.com' }
 }
 }
 
 allprojects {
 repositories {
 maven { url 'https://maven.google.com' }
 }
 }
  12. @MOLSJEROEN CONTENTS ▸ Dependency configurations ▸ Google Maven repository ▸

    Build variants in modules ▸ Android Studio 3.0 features
  13. @MOLSJEROEN OLD BUILD VARIANTS IN MODULES dependencies {
 flav1Compile project(path:

    ':lib1', configuration: 'flav1Release')
 flav2Compile project(path: ':lib1', configuration: 'flav2Release')
 }
  14. @MOLSJEROEN OLD BUILD VARIANTS IN MODULES dependencies {
 flav1Compile project(path:

    ':lib1', configuration: 'flav1Release')
 flav2Compile project(path: ':lib1', configuration: 'flav2Release')
 } android {
 publishNonDefault true
 }

  15. @MOLSJEROEN NEW BUILD VARIANTS IN MODULES ▸ Automatic variant matching

    ▸ Explicitly add every flavor to a dimension flavorDimensions "color"
 
 productFlavors {
 red {
 dimension "color"
 ...
 }
 }
  16. @MOLSJEROEN NEW BUILD VARIANTS IN MODULES ▸ Automatic variant matching

    ▸ Explicitly add every flavor to a dimension flavorDimensions "color"
 
 productFlavors {
 red {
 dimension "color"
 ...
 }
 }
  17. @MOLSJEROEN NEW BUILD VARIANTS IN MODULES ▸ Automatic variant matching

    ▸ Explicitly add every flavor to a dimension dependencies {
 
 debugCompile project(path: ':foo', configuration: 'debug')
 
 implementation project(':foo')
 
 debugImplementation 'com.example.android:app-magic:12.3'
 }
  18. @MOLSJEROEN NEW BUILD VARIANTS IN MODULES ▸ Automatic variant matching

    ▸ Explicitly add every flavor to a dimension dependencies {
 
 debugCompile project(path: ':foo', configuration: 'debug')
 
 implementation project(':foo')
 
 debugImplementation 'com.example.android:app-magic:12.3'
 }
  19. @MOLSJEROEN NEW BUILD VARIANTS IN MODULES ▸ Automatic variant matching

    ▸ Explicitly add every flavor to a dimension dependencies {
 
 debugCompile project(path: ':foo', configuration: 'debug')
 
 implementation project(':foo')
 
 debugImplementation 'com.example.android:app-magic:12.3'
 }
  20. @MOLSJEROEN CONTENTS ▸ Dependency configurations ▸ Google Maven repository ▸

    Build variants in modules ▸ Android Studio 3.0 features
  21. @MOLSJEROEN NEW FEATURES ▸ Adaptive icon wizard ▸ Xml and

    downloadable font supports ▸ Android things support ▸ Faster builds ▸ Improvements to layout editor ▸ Improvements to layout inspector ▸ …