Modifying variant outputs at build time may not work

Using the Variant API to manipulate variant outputs is broken with the new plugin. It still works for simple tasks, such as changing the APK name during build time, as shown below:

// If you use each() to iterate through the variant objects,

// you need to start using all(). That's because each() iterates

// through only the objects that already exist during configuration time—

// but those object don't exist at configuration time with the new model.

// However, all() adapts to the new model by picking up object as they are

// added during execution.

android.applicationVariants.all { variant ->

variant.outputs.all {

outputFileName = "${variant.name}-${variant.versionName}.apk"

}

}

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐