在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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • c#操作xml文件

    c#操作xml文件

    2021年9月4日
    85
  • oracle触发器类型

    http://www.cnblogs.com/roucheng/p/3506033.html触发器是许多关系数据库系统都提供的一项技术。在ORACLE系统里,触发器类似过程和函数,都有声明,执行和异

    2021年12月23日
    56
  • java system.out.print_java面试多久给答复

    java system.out.print_java面试多久给答复学了这么久的面向对象编程,那如何用一行代码体现呢?老师告诉我,如果你能自己读懂System.out.println(),就真正了解了Java面向对象编程的概念System.out.println(“helloworld”);helloworldProcessfinishedwithexitcode0首先分析System源码System就是Java自定义的一个类…

    2022年9月28日
    4
  • eclipse 下载安装教程

    eclipse 下载安装教程之前已经安装了JDK还有环境变量的配置,如果没有弄的,可以看这个JDK以及环境变量配置一、下载eclipse官网的网址:eclipse下载1.有的是下载的压缩包,可以直接放到想要放的位置,解压缩就行,这你就不说了;这里主要是通过installer下载安装2.选择China下载二、安装等待安装完成就行…

    2022年6月3日
    42
  • 关于charles抓包https乱码的设置[通俗易懂]

    关于charles抓包https乱码的设置[通俗易懂]关于charles抓包https乱码的设置charles安装本地证书首先我们点击help->SSLProxying->InstallCharlesRootCertificate安装证书。默认安装证书是不受信任的,双击打开证书,打开信任选择项,将使用此证书时这是为始终信任。安装手机证书点击help->SSLProxying->Inst…

    2022年6月4日
    99
  • CentOS 7系统离线安装gcc,gcc-c++,让你摆脱联网装不了的困惑!

    CentOS 7系统离线安装gcc,gcc-c++,让你摆脱联网装不了的困惑!我的就是CentOs7系统,需要装一个Nginx服务器的时候,死活都装不上运行环境gcc,gcc-c++,一直纠结了几天,后来我睡觉的时候突然一个灵感来了,就继续查资料,如果缺少依赖包,那么就去装依赖包,手动安装或者离线安装都可以。第二天上班的时候我就开始查网上查资料,果然有这种解决办法,并且还有各个依赖包都抽离出来了,感谢各位大佬的分享,我写这个不是为了宣传什么,…

    2022年5月9日
    41

发表回复

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

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