解决Error:All flavors must now belong to a named flavor dimension. Learn more at https://d.android.com
生活随笔
收集整理的這篇文章主要介紹了
解决Error:All flavors must now belong to a named flavor dimension. Learn more at https://d.android.com
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
這個錯誤是說:必須要保證所有的flavor 都屬于同一個維度。
3.0之前配置多版本打包是不會有問題的,可以正常運行、打包。但是AndroidStudio升級到3.0之后,配置多版本打包運行的時候會提示這個錯誤(Error:All flavors must now belong to a named flavor dimension. Learn more at https://d.android.com)
解決辦法:
在defaultConfig{}中添加:
flavorDimensions?"" ? 就可以了
不過最好在屬性里面加入?default,默認
例如:?
flavorDimensions "default"具體代碼位置如下:
defaultConfig { applicationId "com.*********.app" minSdkVersion 15 targetSdkVersion 22 multiDexEnabled true //動態指定版本號版本名 versionCode project.hasProperty('VERSION_CODE') ? Integer.parseInt(VERSION_CODE) : DEF_VERSION_CODEversionName project.hasProperty('VERSION_NAME') ? VERSION_NAME : "${DEF_VERSION_NAME}" println("versionCode = " + versionCode + " versionName = " + versionName)buildConfigField("String", "API_HOST", "${API_RELEASE_HOST}")//必須要保證所有的flavor 都屬于同一個維度 flavorDimensions "default" }
總結
以上是生活随笔為你收集整理的解决Error:All flavors must now belong to a named flavor dimension. Learn more at https://d.android.com的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 常用运行命令大全
- 下一篇: c语言|直角杨辉三角