1

我正在尝试使用风味来构建具有不同资产质量的不同 APK。问题是,在选择了一个构建变体之后,它似乎仍然运行所有的风格,而不仅仅是正确的。

所以我的build.gradle样子是这样的。

task initialize{
     doLast {            
         configureObbFile.execute()
         setupScreenSupport.execute()
     }
} 

android {

  compileSdkVersion 28
  defaultConfig {
      println("Flavor: default")
      applicationId com.test.package
      minSdkVersion 19
      targetSdkVersion 28
      versionName "1.0.0"
  }

  flavorDimensions "AssetSize"
  productFlavors {
      tiny {
          println("Flavor: tiny assests")
          pak_name_suffix = "tiny"
          initialize.execute()
      }
      small {
          println("Flavor: small assests")
          pak_name_suffix = "small"
          initialize.execute()
      }
      normal {
          println("Flavor: normal assests")
          pak_name_suffix = "normal"
          initialize.execute()
      }
      tablet {
          println("Flavor: tablet assests")
          pak_name_suffix = "tablet"
          initialize.execute()
      }
      hightable {
          println("Flavor: hightable assests")
          pak_name_suffix = "hightable"
          initialize.execute()
      }
  }
  [...]
}

我得到这样的构建输出

Executing tasks: [:app:assembleHightableDebug]

> Task :app:configureObbFile

> Task :app:setupScreenSupport
Screens pak_name_suffix = "tiny"

> Task :app:initialize
> Task :app:initialize
> Task :app:initialize
> Task :app:initialize
> Task :app:initialize

> Configure project :app
Flavor: default
Flavor: tiny assests
Flavor: small assests
Flavor: normal assests
Flavor: tablet assests
Flavor: hightable assests

如您所见,它确实app:assembleHightableDebug开头,但它只是从上到下执行所有风格。我希望它只做 HighTable 分区(和默认)。怎么了?我究竟做错了什么?奇怪的是,它似乎只运行一次configureObbFilesetupScreenSupport,带有“微小”的味道。

4

1 回答 1

0

initialize.execute()你应该从你的口味中删除每一行。看看这个以了解如何正确拒绝您的应用程序。

于 2019-03-29T16:16:40.173 回答