gpt4 book ai didi

具有多种构建类型的 Android 多种风格

转载 作者:行者123 更新时间:2023-12-03 03:33:57 25 4
gpt4 key购买 nike

我们有一个具有多种风格的项目,每种风格都有 3 种不同的构建类型:调试、质量检查和发布。

productFlavors {
flavor1 {}

flavor2 {}

flavor3 {}
}

buildTypes {
debug {
applicationIdSuffix ".debug"
}

qa {
applicationIdSuffix ".qa"

}

release {
..
}

但对于每种风格和构建类型,我们需要不同的库依赖项。例如:

compile 'baseUrl:myLibrary:1.0.0:flavor1Release@aar'
compile 'baseUrl:myLibrary:1.0.0:flavor1Qa@aar'
...
compile 'baseUrl:myLibrary:1.0.0:flavor3Qa@aar'

我们可以使用 Groovy 脚本添加这些依赖项吗?

最佳答案

我知道您可以像这样为每个 buildType 定义特定的依赖

debugCompile 'baseUrl:myLibrary:1.0.0:debugLib@aar'
releaseCompile 'baseUrl:myLibrary:1.0.0:release:Lib@aar'
  • 编译:主应用
  • androidTestCompile:测试应用
  • debugCompile:调试构建类型
  • releaseCompile:发布构建类型。

Because it’s not possible to build an APK that does not have an associated Build Type, the APK is always configured with two (or more) configurations: compile and Compile. Creating a new Build Type automatically creates a new configuration based on its name.

它似乎也能很好地处理 flavor ,如所述here (但不使用 flavorDimensions)

为一个变体 (buildType+Flavor) 做这件事似乎需要更多的工作。否则你可以将你的库定义为一个真正的库项目并使用这样的语法

To create a dependency on another published artifact, you need to specify which one to use:

dependencies {
flavor1Compile project(path: ':lib1', configuration: 'flavor1Release')
flavor2Compile project(path: ':lib1', configuration: 'flavor2Release')
}

发件人:http://tools.android.com/tech-docs/new-build-system/user-guide

关于具有多种构建类型的 Android 多种风格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29030840/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com