Android Studio 3.0 Flavor Dimension Issue

后端 未结 7 1646
我寻月下人不归
我寻月下人不归 2020-12-04 05:49

Upgraded to Studio Canary build. My previous project of Telegram Messenger is giving following error.

Error:All flavors must now belong to a named fla

7条回答
  •  遥遥无期
    2020-12-04 06:52

    If you want not to use dimensions you should use this line

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

    but if you want ti use dimensions you should declare your dimension name first and then use this name after THIS example is from the documentations:

    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"
      ...
        }
      }
    }
    ...
    

提交回复
热议问题