Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android build.gradle.kts flavoured implementation

Im converting my build.gradle into build.gradle.kts DSL. So far the conversion was smooth. But im stuck when it comes to flavour dependency before in groovy I used :

nameofflavourImplementation  "some.dependency:1.0.0"

i read a lot about how to do this, no luck with this for example:

val nameofflavour by configurations.creating
nameofflavour(group="",name="some.dependency:1.0.0",ext = "aar")

this cause a compile error that the configuration is not known.

Im using gradle: 6.4.1

EDIT:

productFlavors {
    create("nameofflavour") {
        dimension = "full"
        applicationId = "com.someid.android"
    }

Anyone can help me here?

like image 690
Kitesurfer Avatar asked Mar 02 '23 07:03

Kitesurfer


1 Answers

Since you're using create("nameofflavour"), nameofflavour is registered dynamically. So it needs to be in the scope before dependencies can be declared like this:

val nameofflavourImplementation by configurations
dependencies {
    nameofflavourImplementation("some.dependency:1.0.0")
}

OR

You can directly use it as a string:

dependencies {
    "nameofflavourImplementation"("some.dependency:1.0.0")
}
like image 134
Saurabh Thorat Avatar answered Mar 05 '23 17:03

Saurabh Thorat