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/

5f57d2d205e77e185986459c1b89a874?s=128

Jeroen Mols

July 06, 2017
Tweet

Transcript

  1. 3.

    @MOLSJEROEN CONTENTS ▸ Dependency configurations ▸ Google Maven repository ▸

    Build variants in modules ▸ Android Studio 3.0 features
  2. 4.

    @MOLSJEROEN CONTENTS ▸ Dependency configurations ▸ Google Maven repository ▸

    Build variants in modules ▸ Android Studio 3.0 features
  3. 8.

    @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. 14.

    @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. 15.

    @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. 16.

    @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. 21.

    @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. 22.

    @MOLSJEROEN CONTENTS ▸ Dependency configurations ▸ Google Maven repository ▸

    Build variants in modules ▸ Android Studio 3.0 features
  9. 23.

    @MOLSJEROEN MAVEN REPOSITORY buildscript {
 ...
 
 dependencies {
 maven

    { url 'https://maven.google.com' }
 }
 }
 
 allprojects {
 repositories {
 maven { url 'https://maven.google.com' }
 }
 }
  10. 24.

    @MOLSJEROEN MAVEN REPOSITORY buildscript {
 ...
 
 dependencies {
 maven

    { url 'https://maven.google.com' }
 }
 }
 
 allprojects {
 repositories {
 maven { url 'https://maven.google.com' }
 }
 }
  11. 25.

    @MOLSJEROEN MAVEN REPOSITORY buildscript {
 ...
 
 dependencies {
 maven

    { url 'https://maven.google.com' }
 }
 }
 
 allprojects {
 repositories {
 maven { url 'https://maven.google.com' }
 }
 }
  12. 26.

    @MOLSJEROEN CONTENTS ▸ Dependency configurations ▸ Google Maven repository ▸

    Build variants in modules ▸ Android Studio 3.0 features
  13. 27.

    @MOLSJEROEN OLD BUILD VARIANTS IN MODULES dependencies {
 flav1Compile project(path:

    ':lib1', configuration: 'flav1Release')
 flav2Compile project(path: ':lib1', configuration: 'flav2Release')
 }
  14. 28.

    @MOLSJEROEN OLD BUILD VARIANTS IN MODULES dependencies {
 flav1Compile project(path:

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

  15. 29.

    @MOLSJEROEN NEW BUILD VARIANTS IN MODULES ▸ Automatic variant matching

    ▸ Explicitly add every flavor to a dimension flavorDimensions "color"
 
 productFlavors {
 red {
 dimension "color"
 ...
 }
 }
  16. 30.

    @MOLSJEROEN NEW BUILD VARIANTS IN MODULES ▸ Automatic variant matching

    ▸ Explicitly add every flavor to a dimension flavorDimensions "color"
 
 productFlavors {
 red {
 dimension "color"
 ...
 }
 }
  17. 31.

    @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. 32.

    @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. 33.

    @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. 34.

    @MOLSJEROEN CONTENTS ▸ Dependency configurations ▸ Google Maven repository ▸

    Build variants in modules ▸ Android Studio 3.0 features
  21. 43.

    @MOLSJEROEN NEW FEATURES ▸ Adaptive icon wizard ▸ Xml and

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