12

Inside build.gradle we could

   productFlavors {
        free {
            dimension "tier"
        }
    }

Then

dependencies { freeDebugImplementation "com.someDependency:free-debug:1.0.0";}

BUT when I use Kotlin DSL, inside build.gradle.kts, I

productFlavors { create("free") {...} }

Then in dependencies I can not

dependencies { freeImplementation(...)}

Error: ^ Unresolved reference: freeImplementation So, how can I implementation for specific flavor via Kotlin DSL?

Neil G
  • 203
  • 1
  • 7

3 Answers3

18

I Kotlin DSL flavor specific dependency looks like this:

dependencies { 
    "freeImplementation"(...)
    "paidImplementation"(...)

}
Francis
  • 6,788
  • 5
  • 47
  • 64
4

You should use the sample "YOUR_FLAVOR_NAMEimplementation"

dependencies {

    "freeImplementation" "your dependency is here"
    "paidImplementation" "your dependency is here"
    // Other dependencies 
    }
Alexander
  • 511
  • 4
  • 14
0
productFlavors {
    free {
            .....
         }
    paid {
            ....
         }
}

Write like this in dependencies

dependencies {

        freeImplementation "your dependency is here"
        paidImplementation "your dependency is here"
        // Other dependencies    
}
Nensi Kasundra
  • 1,980
  • 6
  • 21
  • 34