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


相关推荐

  • PCEP 协议学习笔记

    PCEP 协议学习笔记RFC5440章节:PCReq消息响应PCC发送的PCReq的

    2022年9月7日
    0
  • startService bindService 区别「建议收藏」

    startService bindService 区别「建议收藏」Android执行Service有两种方法,一种是startService,一种是bindService。下面让我们一起来聊一聊这两种执行Service方法的区别。 1、生命周期上的区别执行startService时,Service会经历onCreate->onStartCommand。当执行stopService时,直接调用onDestroy方法。调用者如果没有stopService,Se…

    2022年5月25日
    30
  • word在试图打开文件时遇到错误,一种解决办法[通俗易懂]

    word在试图打开文件时遇到错误,一种解决办法[通俗易懂]1.双击word打开时弹出错误窗口弹出错误,无法打开word;2.解决办法此时右键打开word的属性窗口:选择下面的解除锁定,点击;锁定解除后,就可以正常打开word进行查看了。

    2022年6月4日
    34
  • IDEA maven项目打jar包方式总结

    IDEA maven项目打jar包方式总结IDEAmaven项目导出jar包方式总结

    2022年6月19日
    43
  • zigbee开发板(nxpzigbee开发)

    前面我们搭建好了zigbee开发的硬件平台,买一块开发板,注意只要这块开发板上有cc2530,可以向里面烧录程序就可以了。具体的烧录过程我会最近上传我的烧录过程,相关软件我尽快上传。好了回归这一次的主题,那么我们到底需要什么样的开发环境呢?这完全取决于你的项目大小,如果你的项目只是学会使用zigbee,那么你只需要一款烧录软件,以及一款合适的用于编写cc2530的c编译器就OK了。但是我这

    2022年4月10日
    54
  • 2021 idea 激活码(JetBrains全家桶)

    (2021 idea 激活码)这是一篇idea技术相关文章,由全栈君为大家提供,主要知识点是关于2021JetBrains全家桶永久激活码的内容IntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,下面是详细链接哦~https://javaforall.net/100143.htmlMLZPB5EL5Q-eyJsaWN…

    2022年3月21日
    80

发表回复

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

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