美文网首页
kts kotlin高级 玩转flavor玩转继承和多维组合

kts kotlin高级 玩转flavor玩转继承和多维组合

作者: 吉凶以情迁 | 来源:发表于2024-01-21 11:32 被阅读0次
    image.png

    首先给到官网的说法

    Specifies the flavor dimension that this product flavor belongs to.
    When configuring product flavors with Android plugin 3.0.0 and higher, you must specify at least one flavor dimension, using the flavorDimensions property, and then assign each flavor to a dimension. Otherwise, you will get the following build error:
    Error:All flavors must now belong to a named flavor dimension.
    The flavor 'flavor_name' is not assigned to a flavor dimension.
    
    By default, when you specify only one dimension, all flavors you configure automatically belong to that dimension. If you specify more than one dimension, you need to manually assign each flavor to a dimension, as shown in the sample below:
    android {
        ...
        // 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', 'version'
    
        productFlavors {
            demo {
                // Assigns this product flavor to the 'version' flavor dimension.
                dimension 'version'
                ...
            }
    
            full {
                dimension 'version'
                ...
            }
    
            minApi24 {
                // Assigns this flavor to the 'api' dimension.
                dimension 'api'
                minSdkVersion '24'
                versionNameSuffix "-minApi24"
                ...
            }
    
            minApi21 {
                dimension "api"
                minSdkVersion '21'
                versionNameSuffix "-minApi21"
                ...
            }
        }
    }
    
    
    
    
    

    一些推荐的教程
    knight-kk/knight_blog_demo: 博客中 demo ,博客地址 https://blog.csdn.net/knight1996/ (github.com)
    https://juejin.cn/post/7031399811173744648

    步入正题
    10个客户10个flavor ,其中一个客户两个地方,需要指定不同的ip,怎么搞

    不想定义2个channel,
    咋实现第一个channel共用第二个channel是否还有其他办法实现,
    我做的有一个客户他有两个地域,区别只是ip端口,
    而不是模块的区别,所以没必要拷贝一模一样的,我每次都改build配置感觉不得劲

    我的思路有2个方法,第一个方法思路都是通过flavor

    思路1:

    有10个客户 ,分别abcd以此类推

    a客户有连个地域,不同的服务器

    mychannel有10个分别abcdefg**

        flavorDimensions += listOf("mychannel", "version")
    

    相关文章

      网友评论

          本文标题:kts kotlin高级 玩转flavor玩转继承和多维组合

          本文链接:https://www.haomeiwen.com/subject/evreodtx.html