简体   繁体   中英

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?

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")
}

When using:

val nameofflavour by configurations

dependencies {
  ...

i get again a compile error: Configuration with name 'nameofflavour' not found.

Using the "nameofflavourImplementation"("some.dependency:1.0.0") approach gives an Build Failure:

> Could not resolve all task dependencies for configuration ':app:nameofflavourDebugCompileClasspath'.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM