升级到Studio Canary构建。我以前的Telegram Messenger项目是给以下错误。

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

我该怎么办?我已经看到了这个链接,但不知道该怎么做。我现在有3个版本,发布版本,调试版本和自由/开源版本。


当前回答

经过尝试和仔细阅读,我自己解决了。 解决方案是在build.gradle中添加以下行。

flavorDimensions“versionCode”

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

其他回答

如果您真的不需要这种机制,只需在构建中指定一个随机的风味维度。Gradle或build.gradle.kts:

android { 
    ...
    flavorDimensions("default")
    ...
}

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

经过尝试和仔细阅读,我自己解决了。 解决方案是在build.gradle中添加以下行。

flavorDimensions“versionCode”

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

如果您有简单的口味(免费/专业,演示/完整等),然后添加到构建。gradle文件:

android {
...
flavorDimensions "version"
productFlavors {
        free{
            dimension "version"
            ...
            }
        pro{
            dimension "version"
            ...
            }
}

通过维度,您可以创建“口味中的口味”。阅读更多。

在这里你可以解决这个问题,你需要添加productFlavors的名称flavorDimension,并需要定义维度,参见下面的示例,更多信息请参阅https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html

flavorDimensions 'yourAppName' //here defined dimensions
productFlavors {
    production {
        dimension 'yourAppName' //you just need to add this line
        //here you no need to write applicationIdSuffix because by default it will point to your app package which is also available inside manifest.xml file.

    }

    staging {
        dimension 'yourAppName' //added here also
        applicationIdSuffix ".staging"//(.staging) will be added after your default package name.
        //or you can also use applicationId="your_package_name.staging" instead of applicationIdSuffix but remember if you are using applicationId then You have to mention full package name.
        //versionNameSuffix "-staging"

    }

    develop {
        dimension 'yourAppName' //add here too
        applicationIdSuffix ".develop"
        //versionNameSuffix "-develop"

    }

我在构建中使用了flavorDimensions。gradle(模块:app)

flavorDimensions "tier"

productFlavors {
    production {
        flavorDimensions "tier"
        //manifestPlaceholders = [appName: APP_NAME]
        //signingConfig signingConfigs.config
    }
    staging {
        flavorDimensions "tier"
        //manifestPlaceholders = [appName: APP_NAME_STAGING]
        //applicationIdSuffix ".staging"
        //versionNameSuffix "-staging"
        //signingConfig signingConfigs.config
    }
}

点击这个链接了解更多信息

// Specifies two flavor dimensions.
flavorDimensions "tier", "minApi"

productFlavors {
     free {
            // Assigns this product flavor to the "tier" flavor dimension. Specifying
            // this property is optional if you are using only one dimension.
            dimension "tier"
            ...
     }

     paid {
            dimension "tier"
            ...
     }

     minApi23 {
            dimension "minApi"
            ...
     }

     minApi18 {
            dimension "minApi"
            ...
     }
}