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

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

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


当前回答

在这里你可以解决这个问题,你需要添加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"

    }

其他回答

在KotlinDSL中,你可以这样使用:

flavorDimensions ("PlaceApp")
productFlavors {
    create("tapsi") {
        setDimension("PlaceApp")
        buildConfigField("String", "API_BASE_URL", "https://xxx/x/x/")
    }

}

如果您真的不需要这种机制,只需在构建中指定一个随机的风味维度。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"

    }