- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我的应用程序中,我管理Gradle
中的所有buildSrc
内容。其中之一是buildTypes
。我能够访问buildTypes
提供的所有属性。但是,我无法访问applicationVariants
中的buildSrc
。有什么办法吗?
Sample code block in buildSrc/BuildTypes.kt
internal object Debug : BuildTypeCreator {
override val name = InternalBuildType.DEBUG
override fun create(
namedDomainObjectContainer: NamedDomainObjectContainer<BuildType>,
project: Project,
isLibrary: Boolean,
closure: BuildType.() -> Unit
): BuildType {
return namedDomainObjectContainer.maybeCreate(name).apply {
if (isLibrary) {
versionNameSuffix = "-dev-${project.gitSha}"
} else {
applicationIdSuffix = ".dev"
}
isTestCoverageEnabled = true
isMinifyEnabled = false
isDebuggable = true
closure.invoke(this)
}
}
}
Sample code block in app.gradle.kts(which I want to achieve the same in buildSrc)
applicationVariants.all { -> **This is not accessible in buildSrc**
if (buildType.name == getByName("release").name) {
outputs.all { output: BaseVariantOutput ->
val outputImpl = output as BaseVariantOutputImpl
outputImpl.outputFileName = "calendar-view.apk"
true
}
}
}
最佳答案
好的,我通过传递参数domainObjectSet: DomainObjectSet<ApplicationVariant>
解决了它
关于android - 在buildSrc中访问ApplicationVariants,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59684596/
我正在使用 Gradle 编译我的 Android 项目: buildTypes { release { signingConfig signingConfigs.releas
Android build.gradle 指令通常有类似 的部分 applicationVariants.all { variant -> variant.outputs.each { out
我在 Android 应用程序项目的 Kotlin Dsl 文件中使用以下简化配置。 class ApplicationVariantAction : Action { overrid
我注意到application.applicationVariants.size()总是返回0,尽管我知道有变体,因为我可以迭代它们:android.applicationVariants.all {
我最近将一个项目从gradle 2.1.0迁移到了gradle experimental plugin 0.7.0 在我的 2.1.0 脚本中,我有根据特定命名约定重命名 APK 的脚本。项目名称,后
我有一个与 this question 类似的问题 Could not get unknown property 'applicationVariants' for object of type co
我正在尝试解决 Gradle 的一个恼人问题,该问题不允许库具有不同的 min/target sdk。解决方案是将以下内容添加到 build.gradle。 android.applicationVa
我已经在我的项目中导入了模块并且正确导入了。但是我收到了这个错误。我已经导入了扫描仪控制应用程序模块(由 zebra 提供)。我已经搜索了许多替代解决方案,但没有成功。 Error:(36, 0) C
我尝试将其转换为 Kotlin: applicationVariants.all { variant -> def flavor = variant.productFlavors[0]
我是一名优秀的程序员,十分优秀!