在Android Library的Module中按渠道依赖

在Android Library的Module中按渠道依赖

Finally I found out how to do this, I will explain it here for others facing same problem:

The key part is to set publishNonDefault to true in library build.gradle, Then you must define dependencies as suggested by user guide.

The whole project would be like this:

Library build.gradle:

apply plugin: 'com.android.library'

android {        
    ....
    publishNonDefault true
    productFlavors {
        market1 {}
        market2 {}
    }
}

project build.gradle:

apply plugin: 'com.android.application'

android {
    ....
    productFlavors {
        market1 {}
        market2 {}
    }
}

dependencies {
    ....
    market1Compile project(path: ':lib', configuration: 'market1Release')
    market2Compile project(path: ':lib', configuration: 'market2Release')
}

Now you can select the app flavor and Build Variants panel and the library will be selected accordingly and all build and run will be done based on the selected flavor.

If you have multiple app module based on the library Android Studio will complain about Variant selection conflict, It’s ok, just ignore it.

enter image description here

 

其他参考

https://stackoverflow.com/questions/24307596/how-can-i-add-flavors-in-a-module-with-android-studio

转载于:https://my.oschina.net/sfshine/blog/2870349

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/101336.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Zigbee 协议栈

    Zigbee 协议栈Zigbee协议栈平台协议栈对我们的作用怎么使用协议栈协议栈的安装、编译与下载Components(部件)Documents(文件)Projects(项目例子)Tools(工具)平台协议TIZStack-CC2530-2.5.1a协议栈对我们的作用协议栈是协议的实现,可以理解为代码,函数库,供上层应用调用,协议较底下的层与应用是相互独立的。商业化的协议栈就是给你写好了底层的代码,符合协议标准,提供给你一个功能模块给你调用。你需要关心的就是你的应用逻辑,数据从哪里到哪里,怎么存储,处

    2022年5月28日
    35
  • VScode常用插件_AE必备插件

    VScode常用插件_AE必备插件这篇博客主要是我使用vscode过程中的插件汇总,使用了这么长时间,总想有个总结,也方便日后查看,这里我将我使用的插件分为基础、框架、工具三个类型。官网地址VSCode插件官网地址,里面有很多的插件可以使用。基础插件这部分插件主要是和html、css、js有关的。htmlCSSSupport这个插件支持以下语言,提供基础的语法知识编写辅助。这是插件地址htmllarav…

    2022年9月30日
    4
  • PHP蜘蛛爬虫开发文档

    PHP蜘蛛爬虫开发文档

    2021年11月4日
    48
  • matlab Lasso回归

    matlab Lasso回归Lasso回归clc,clear;closeall;data=[1.541.611.621.661.711.721.731.861.9222.212.292.342.382.422.442.572.642.712.852.933.013.143.223.343.493.553.793.994.1220.120.120.320.420.420.520.620.720.921.121.321.521

    2022年5月22日
    91
  • JAVA四舍五入保留一位小数

    JAVA四舍五入保留一位小数newBigDecimal(speed).setScale(1,BigDecimal.ROUND_HALF_UP).doubleValue()

    2022年5月11日
    55
  • iReport 分组统计[通俗易懂]

    iReport 分组统计[通俗易懂]参考http://jaspereport.group.iteye.com/group/wiki/3401-jaspereport-ireport做出了分组统计的效果。1、在报表中新建一个group2、新建一个变量,设置属性3、在报表中插入一个TextField,设置相关分组属性。

    2025年10月19日
    2

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号