解决Error:All flavors must now belong to a named flavor dimension
生活随笔
收集整理的這篇文章主要介紹了
解决Error:All flavors must now belong to a named flavor dimension
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
前言
最近寫的項目越來越大,出現(xiàn)了64K問題,所以用了Multidex來突破64K方法數(shù)限制,然后為了優(yōu)化編譯速度在build.gradle文件中加入了如下代碼
productFlavors {// Define separate dev and prod product flavors.dev {// dev utilizes minSDKVersion = 21 to allow the Android gradle plugin// to pre-dex each module and produce an APK that can be tested on// Android Lollipop without time consuming dex merging processes.minSdkVersion 18}prod {// The actual minSdkVersion for the application.minSdkVersion 16}}可是編譯后卻出現(xiàn)了如下問題。
出現(xiàn)的原因
經(jīng)過在網(wǎng)上查閱資料發(fā)現(xiàn)是因為Plugin 3.0.0之后有一種自動匹配消耗庫的機制,便于debug variant 自動消耗一個庫,然后就是必須要所有的flavor 都屬于同一個維度。為了避免flavor 不同產(chǎn)生誤差的問題,應(yīng)該在所有的庫模塊都使用同一個foo尺寸。
解決問題
在主app的build.gradle里面的進行修改。
defaultConfig {targetSdkVersion:***minSdkVersion :***versionCode:***versionName :***//版本名后面添加一句話,意思就是flavor dimension 它的維度就是該版本號,這樣維度就是都是統(tǒng)一的了flavorDimensions "versionCode" }個人技術(shù)博客:https://myml666.github.io
總結(jié)
以上是生活随笔為你收集整理的解决Error:All flavors must now belong to a named flavor dimension的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 金蝶生成凭证模板_金蝶k3凭证生成
- 下一篇: 计算机分区容量计算公式,硬盘整数分区计算