将Android的moudle上传到maven仓库
平常我们编写Android项目的时候,Androidstudio只需要添加一个complie就可以添加依赖,实现代码的复用 轻轻松松,然后我就想怎么做的,现在我们一步步来
1.注册jcenter账号
这一步之前遇到过一个坑,我是用 https://bintray.com 这个企业地址注册的,导致自己的项目需要等待一个月的审核才能 add to jcenter 上去,这里需要注意一 下,正确的个人地址是:https://bintray.com/signup/oss ,https://bintray.com/signup/oss ,https://bintray.com/signup/oss (重要的事情说三遍)注册界面如下

2.注册成功后登陆到主界面
点击偏左上方的edit按钮进入到my profile中,点击左侧的apiKey,再输入密码查看自己的apikey,保存下来,马上会用到

3.在主页面点击
新建一个mavenrepository,我这里取得是whitehouse,名字可以自己定义,不一定要是maven,新建完成之后如下图所示:

4.配置AndroidStudio
关于jcenter上的工作做了差不多了,打开AndroidStudio,在最外层(整个项目的build.gradle)里的builscript加入下面两行代码,

classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.novoda:bintray-release:0.3.4'
然后在需要上传的library最上面的位置增加
[java] view plaincopy
apply plugin: 'com.novoda.bintray-release'
在android{}里面增加
[java] view plaincopy
lintOptions {
abortOnError false
}
接下来在最后

第一个是用户的名字,就是注册名,第二个是生成依赖包的时候jcenter上的路径,可自定义,第三个是上传之后项目的名称,第四个是版本号,用来更新使用,reponame就是自己闯将的repository的名字,这里我用的是whitehouse。
5.上传
打开terminal敲入如下代码
./gradlew clean build bintrayUpload -PbintrayUser=luzhichao -PbintrayKey=f476eff258b0d52770xxxxxxxxxxxxx -PdryRun=false
这里用到我们上面的apikey的值,上传需要注意,上传之前要确保能够build过去,此外方法注解当中中的param,return等都需要有描述,不然会build failed。一切准备就绪,可以开始上传了,成功之后将会在respository里看到上传的项目了。

点击进去,找到link to jcenter 按钮,进去之后出现

点击send,等待两个小时之后,就可以用
compile 'com.luzhichao:datepicker:1.0.0'
这一行代码将项目轻松引入进来啦~