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. @MOLSJEROEN MIGRATING TO ANDROID STUDIO 3.0

  2. @MOLSJEROEN @MOLSJEROEN

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

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

    Build variants in modules ▸ Android Studio 3.0 features
  5. @MOLSJEROEN OLD DEPENDENCY CONFIGURATIONS

  6. @MOLSJEROEN OLD DEPENDENCY CONFIGURATIONS

  7. @MOLSJEROEN dependencies {
 
 compile 'com.jeroenmols:moduleB:1.0.0'
 } OLD DEPENDENCY CONFIGURATIONS

  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
  9. @MOLSJEROEN OLD DEPENDENCY CONFIGURATIONS - IMPLEMENTATION CHANGE

  10. @MOLSJEROEN OLD DEPENDENCY CONFIGURATIONS - ABI CHANGE

  11. @MOLSJEROEN OLD DEPENDENCY CONFIGURATIONS - ABI CHANGE

  12. @MOLSJEROEN OLD DEPENDENCY CONFIGURATIONS - ABI CHANGE

  13. @MOLSJEROEN OLD DEPENDENCY CONFIGURATIONS - ABI CHANGE

  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
  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
  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
  17. @MOLSJEROEN dependencies {
 
 implementation ‘com.jeroenmols:myawesomelibrary:1.0.0’
 } NEW DEPENDENCY CONFIGURATIONS

  18. @MOLSJEROEN NEW DEPENDENCY CONFIGURATIONS - IMPLEMENTATION

  19. @MOLSJEROEN dependencies {
 
 api ‘com.jeroenmols:myawesomelibrary:1.0.0’
 } NEW DEPENDENCY CONFIGURATIONS

  20. @MOLSJEROEN NEW DEPENDENCY CONFIGURATIONS - API

  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
  22. @MOLSJEROEN CONTENTS ▸ Dependency configurations ▸ Google Maven repository ▸

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

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

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

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

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

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

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

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

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

    ▸ Explicitly add every flavor to a dimension flavorDimensions "color"
 
 productFlavors {
 red {
 dimension "color"
 ...
 }
 }
  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'
 }
  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'
 }
  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'
 }
  34. @MOLSJEROEN CONTENTS ▸ Dependency configurations ▸ Google Maven repository ▸

    Build variants in modules ▸ Android Studio 3.0 features
  35. @MOLSJEROEN ANDROID 3.0 FEATURES

  36. @MOLSJEROEN DEVICE FILE EXPLORER ▸ adb exec-out run-as package.name cat

    databases/file > file
  37. @MOLSJEROEN APK ANALYZER SUPPORTS PROGUARD

  38. @MOLSJEROEN INSTANT APPS

  39. @MOLSJEROEN NEW PROFILERS

  40. @MOLSJEROEN NEW PROFILERS

  41. @MOLSJEROEN NEW PROFILERS

  42. @MOLSJEROEN NEW PROFILERS

  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 ▸ …
  44. @MOLSJEROEN MANY THANKS ▸ Jeroen Mols (Belgium) ▸ @MolsJeroen ▸

    http://jeroenmols.com/blog