Android上传项目到jcenter(基于最新bintray-
转载请标明出处:
https://www.jianshu.com/p/c5ce7df4da17
本文出自:YoriZ
参考文章:
前言
截止2019.02.15现有关于novoda组件的文章在gradle4.5都已经不能正常运行,因此有了此片文章,以下为异常信息:
com.novoda.gradle.release.AndroidLibrary$LibraryUsage.getDependencyConstraints()Ljava/util/Set
github issues address
结论就是gradle更新到4.5后与novada组件有冲突,而解决办法是作者发布的新库StefMa/bintray-release
StefMa/bintray-release
本文便是基于新库介绍使用方法
在这里还有一个关于Kotlin语言使用这个组件的坑,他会用到dokka,而使用dokka又会引起另一个异常:
Exception while loading package-list from ExternalDocumentationLinkImpl
github issues address
可以看到这是2017年9月开的Issues,至今还是Open状态,内部说的大部分是因为网络原因无法获取package-list,可在本人挂了代理多次尝试后并无办法解决,最终通过2018年7月大佬的回复解决了此问题
整体流程
1.配置bintray
注册地址:https://bintray.com/signup/oss
如果你是从鸿洋大神文章网址跳过去记得注册开源账户,不然注册是企业账户要审核的

登录后点击Edit找到你的API Key并保存,在之后你上传时会使用到

回到首页,新建一个库


至此bintray就配置完毕了
2.配置项目
- 1.新建待上传模块
首先你得有一个AndroidLibrary,在项目中new一个Module,然后选择Android Library创建

这个Module中就是你需要上传上去的包,具体代码自行添加进去哦在这里我就不说了

- 2.配置项目build.gradle
接下来打开项目的build.gradle,并在buildscript中的dependencies添加
classpath "guru.stefma.bintrayrelease:bintrayrelease:1.1.2"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:0.9.17"
bintrayrelease版本查看地址
dokka版本查看地址
如果代码中含有中文(包括注释),在allprojects中添加
tasks.withType(Javadoc) {
options {
encoding "UTF-8"
charSet 'UTF-8'
links "http://docs.oracle.com/javase/7/docs/api"
}
}

- 3.配置模块build.gradle
接下来到要发布的模块中的build.gradle添加
apply plugin: "guru.stefma.bintrayrelease"
version="1.0.0" //版本号
group = "com.yoriz" //jcenter的路径,可以随便自定义
//当前这个bintrayRelease依赖于AndroidArtifacts
androidArtifact{
artifactId = "bintrayrelease"
}
publish{
userOrg = 'yoriz' //bintray用户名
repoName = 'RepositoryName' //要传过去的库名
artifactId = 'mylibrary' //要传过去的项目名
desc = 'This is used to write articles' //描述
website = 'https://github.com/Crazyya/AndroidFastFramework' // 项目网站,尽量用对,因为在之后上传到jcenter的时候会检查,不过那个时候再改也没问题
}

3.上传到bintray
打开AndroidStudio下方菜单栏的Terminal输入以下命令
Windows:
gradlew clean build bintrayUpload -PbintrayUser=你的bintray用户名 -PbintrayKey=刚才让保存的APIKey -PdryRun=false
Mac:
./gradlew clean build bintrayUpload -PbintrayUser=你的bintray用户名 -PbintrayKey=刚才让保存的APIKey -PdryRun=false

接下来就是等待执行完成

4.添加到Jcenter
回到你的bintray首页并点击模块中指定的库
此时你能看到你刚才传的包,点击进入

此时点击右上方Actions,在弹出的菜单栏中选择Add to Jcenter

点击Send

接下来就是等待库管理员审核通过,审核完毕后会向你的bintray账号发送邮件,就在网页最上方有个信封图标那里,审核通过后就可以使用了


结尾
以上就是本篇文章的所有内容了,如有任何建议或疑问欢迎留言