[英]android build.gradle.kts flavoured implementation
Im converting my build.gradle
into build.gradle.kts
DSL.我将我的build.gradle
转换为build.gradle.kts
DSL。 So far the conversion was smooth.到目前为止,转换很顺利。 But im stuck when it comes to flavour dependency before in groovy I used:但是在我之前使用的 groovy 中,当涉及到风味依赖时,我陷入了困境:
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我正在使用 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.由于您使用的是create("nameofflavour")
, nameofflavour
是动态注册的。 So it needs to be in the scope before dependencies can be declared like this:所以它需要在 scope 中,然后才能像这样声明依赖项:
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.我再次遇到编译错误:找不到名称为“nameofflavour”的配置。
Using the "nameofflavourImplementation"("some.dependency:1.0.0") approach gives an Build Failure:使用 "nameofflavourImplementation"("some.dependency:1.0.0") 方法会导致构建失败:
> Could not resolve all task dependencies for configuration ':app:nameofflavourDebugCompileClasspath'.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.