Android Studio 3.0风味维度问题

升级到工作室金丝雀生成。 我之前的Telegram Messenger项目出现以下错误。

错误:所有的味道现在都必须属于一个命名的味道维度。 风味'armv7'没有被分配到风味维度。 通过https://d.android.com/r/tools/flavorDimensions-missing-error-message.html了解更多信息

我该怎么办? 我已经看到了这个链接,但不知道该怎么做。 我现在有3个版本的变体,发布,debugging和foss。

如果你不需要这个机制,只需指定一个随机的风格维度:

android { ... flavorDimensions "default" ... } 

有关更多信息,请查看迁移指南

仔细阅读后,我自己解决了。 解决scheme是在build.gradle中添加以下行。

flavorDimensions“versionCode”

 android { compileSdkVersion 24 ..... flavorDimensions "versionCode" } 

如果你不想使用尺寸,你应该使用这一行

 android { compileSdkVersion 24 ... flavorDimensions "default" ... } 

但是如果您想要使用维度,则应首先声明维度名称,然后在此示例来自文档之后使用此名称:

 android { ... buildTypes { debug {...} release {...} } // Specifies the flavor dimensions you want to use. The order in which you // list each dimension determines its priority, from highest to lowest, // when Gradle merges variant sources and configurations. You must assign // each product flavor you configure to one of the flavor dimensions. flavorDimensions "api", "mode" productFlavors { demo { // Assigns this product flavor to the "mode" flavor dimension. dimension "mode" ... } full { dimension "mode" ... } // Configurations in the "api" product flavors override those in "mode" // flavors and the defaultConfig block. Gradle determines the priority // between flavor dimensions based on the order in which they appear next // to the flavorDimensions property above--the first dimension has a higher // priority than the second, and so on. minApi24 { dimension "api" minSdkVersion 24 // To ensure the target device receives the version of the app with // the highest compatible API level, assign version codes in increasing // value with API level. To learn more about assigning version codes to // support app updates and uploading to Google Play, read Multiple APK Support versionCode 30000 + android.defaultConfig.versionCode versionNameSuffix "-minApi24" ... } minApi23 { dimension "api" minSdkVersion 23 versionCode 20000 + android.defaultConfig.versionCode versionNameSuffix "-minApi23" ... } minApi21 { dimension "api" minSdkVersion 21 versionCode 10000 + android.defaultConfig.versionCode versionNameSuffix "-minApi21" ... } } } ...