【Gradle】Library库工程的release及debug
来源:互联网 发布:iptv管理系统php 编辑:程序博客网 时间:2024/06/05 03:26
背景:
目前工程中是通过手动在代码中修改debug及release变量,这十分低效并且极易遗忘而造成低级错误。
需求是什么?
1.genkins上打aar包时候,直接根据genkins参数设置来决定打debug还是release包
2.本地工程依赖,需要能区分依赖debug还是release版本
库工程打包所遇到问题:
Library projects only publish their release variants for consumption by other projects or modules.
We’re working at fixing this but this is non trivial and requires a significant amount of work.
目前因为gradle的限制 android库工程只能发布release包 .见 https://code.google.com/p/android/issues/detail?id=52962 中的issue讨论
根据【参考1】的内容,借助publishNonDefault true 可改变这一现状。
本地工程依赖
库工程build.gradle中加上编译参数
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
使用debug编译类型
App工程build.gradle加上工程依赖 debugCompile project(path: ‘:train’, configuration: ‘debug’)
使用release编译类型时
compile project(path: ‘:train’)
此时默认是为release,如果在Build Variants中强制选择为debug,就会报冲突,如【图1】
genkins上打aar包
genkins 执行assembleDebug 可以得到 XXX-debug.aar.
执行assembleRelease 可以得到 XXX-release.aar.
资料
android官方资料
https://guides.codepath.com/android/Building-your-own-Android-library#add-the-gradle-dependency
【图1】
【参考1】
来自 http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Referencing-a-Library
Library Publication
缺省情况下,无论你选用什么Build variant ,库工程都只会打出release包,这是由于Gralde语言的限制造成的,但如果想强制使用debug,可以如下指定:
- 1
- 2
- 3
defaultPublishConfig右边的Build variant量需要是variant全名,出现 Release and debug 的情况只有在没有设置flavor的前提下。如果有flavor就得如下:
- 1
- 2
- 3
也可以设置打所有Build variant的包,在project-to-project依赖(工程依赖)的时候该功能显的很有用(google正在做,但是因为gradle的限制,有可能不work),该功能默认不开启的。
- 1
- 2
- 3
- 1
- 2
- 3
- 4
Important: Note that the published configuration is a full variant, including the build type, and needs to be referenced as such.
Important: When enabling publishing of non default, the Maven publishing plugin will publish these additional variants as extra packages (with classifier). This means that this is not really compatible with publishing to a maven repository. You should either publish a single variant to a repository OR enable all config publishing for inter-project dependencies.
来自:http://blog.csdn.net/xude1985/article/details/51548245
- 【Gradle】Library库工程的release及debug
- 【Gradle】管理库工程release及debug
- vc工程的debug 和release
- Android Studio 中Gradle配置debug使用release的签名
- 使用Gradle管理Debug/Release版本的Key
- Android Gradle配置Debug和release参数的方法
- Android Gradle配置Debug和release参数的方法
- cocos2dx: win32工程Release 和 Debug版本使用的标准库
- viusal c++如何编译工程的debug release版本
- 使用Gradle生成library工程的jar包
- Debug&Release的不同
- debug release 的区别
- qDebug()的输出控制及qmake的debug和release
- 批处理清理VS工程目录(递归删除Debug, Release, ipch目录及*.sdf文件)
- Release和Debug程序的不同及异常处理
- VC6.0 debug和release的区别及如何设置
- VC6.0 debug和release的区别及如何设置
- VC6.0 debug和release的区别及如何设置
- 如何部署MongoDB分片集群?
- 智能手机的发展未来:2017 苹果Apple 10周年秋季发布会 解析
- 版本更新
- oracle初级教程(链接)
- 软件许可证的设计思路
- 【Gradle】Library库工程的release及debug
- SPOJ 422 Transposing is Even More Fun(Polya计数)
- 4925: 城市规划
- WIN7安装DirectSDK
- com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: 2 字节的 UTF-8 序列的字节 2 无效。
- POJ1233 Prim Kruskal
- 高性能服务器架构小结
- CodeForces Round#433
- 一道面试题