热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

AndroidStudio3.0FlavorDimension问题

如何解决《AndroidStudio3.0FlavorDimension问题》经验,为你挑选了5个好方法。

升级到Studio Canary构建.我之前的Telegram Messenger项目给出了以下错误.

错误:所有风味现在必须属于命名风味维度.风味'armv7'未分配给风味维度.有关详细信息,请访问https://d.android.com/r/tools/flavorDimensions-missing-error-message.html

我该怎么办?我已经看过那个链接,但无法理解该怎么做.我现在有3个构建变体,发布,调试和foss.



1> tknell..:

如果您不需要该机制,只需在您的build.gradle:中指定随机风味维度:

android { 
    ...
    flavorDimensions "default"
    ...
}

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


如果您只有一个维度,则无需在每个样式中指定它.只需要第一个`flavorDimensions"默认的"`行就可以了.
flavorDimensions"versionCode"productFlavors {debug {dimension"default"versionName"1.0"} release {dimension"default"versionName"1.0"} foss {dimension"default"versionName"1.0"}}我收到此错误..ProductFlavor名称不能碰撞使用BuildType名称.你能帮助我吗?我得到了这个错误AS 3.0测试版金丝雀与Kotlin.

2> Omkar Nath S..:

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

flavorDimensions"versionCode"

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


为什么**"versionCode"**而不是别的什么?它会影响versionCode吗?
在gradle中你添加这一行?更多的背景会有所帮助
在build.gradle文件中,在android {...}中

3> Abdul Rizwan..:

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

    }



4> 小智..:

如果您不想使用尺寸,则应使用此线

android { 
compileSdkVersion 24

...
flavorDimensions "default"
...
}

但是如果您想要使用尺寸,则应首先声明尺寸名称,然后在此示例来自文档后使用此名称:

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



5> Ranjit Chand..:

我在build.gradle中使用了flavorDimensions作为我的应用程序(Module: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"
            ...
     }
}


推荐阅读
author-avatar
semb
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有