Picking a specific build type in a dependency

后端 未结 5 2409
闹比i
闹比i 2021-02-20 07:14

Suppose I have an Android app with three build types:

buildTypes {
    release {
        ....
    }
    optRelease {
        ....
    }
    debug {
        ....
         


        
5条回答
  •  独厮守ぢ
    2021-02-20 07:28

    Starting from gradle 3.0.0 you can use following for default project variants (release, debug, test etc)

    • implementation
    • releaseImplementation
    • testImplementation
    • debugImplementation
    • androidTestImplementation

    Simple example would be:

    android {
       ....
    }
    dependencies {
        implementation "com.google.dagger:dagger-android-support:$DAGGER_VERSION"
        androidTestImplementation jUnit
        testImplementation mockito
    }
    

    If you have multiple flavors of your app, starting from 3.0 you have to declare flavor dimensions first, define fallback and matching strategy in your default config (for remote dependencies, and dependencies without dimensions) and gradle will recognize what dependencies should be included for that flavor. For more info check this migration guide.

提交回复
热议问题