使用Bintray-极简上传Library到JCenter
1.到bintray网址注册自己的账号。可以已google账号,或者github账号登录。
- 注意但是邮箱不能填写国内的邮箱。
注册等参考资料
新版Bintray-极简上传Library到JCenter
新版Bintray-极简上传Library到JCenter2
2.创建自己的仓库

注意:创建的maven仓名字和类型都要写成maven

3.获取注册名和key值备用

4.项目配置
-
1.根目录下的build.gradle中加入上传开源库的依赖:
classpath 'com.novoda:bintray-release:+'
-
2.library的moudel中加入 apply
apply plugin: 'com.novoda.bintray-release'
publish {
repoName="ToastMessage"//你的仓库名称,就是你创建的仓库的名称
userOrg = 'dandelion***' //bintray注册的用户名
groupId = 'com.puxiaoshuai' //compile引用时的第1部分groupId
artifactId = 'ToastMessage' //compile引用时的第2部分项目名
publishVersion = '0.1.0' //compile引用时的第3部分版本号
desc = 'This is a String to show message '//d项目描述
website = 'https://github.com/puxiaoshuai/Hellolibrary' //github 托管地址
}

-
3.其他配置
-
如果你开源库中有中文注释在moudel的build.gradle加入格式
allprojects {
repositories {
jcenter()
}
//加上这些
tasks.withType(Javadoc) {
options{ encoding "UTF-8"
charSet 'UTF-8'
links "http://docs.oracle.com/javase/7/docs/api"
}
}
}
-
忽略错误信息:moudel的build.gradle
android {
******
******
lintOptions {
abortOnError false
}
}
配置完成后,进行上传
gradlew clean build bintrayUpload -PbintrayUser="注册名" -PbintrayKey=APPKEY -PdryRun=false
注册名,就是前面的备用的user名,APPKEY就是备用的key,

成功之后,到bintray查看,

这样就表示成功了。点击红框,进入详情

点击add to jcenter。填写提交、最好用英文描述。然后一般需要等待审核通过,一般5-6小时.如何知道审核成功了呢?
通过后在Linked to 的下面会出现一个Jcenter的

依赖使用
在审核没有过之前,可以使用私有的来使用

在根目录下build.gradle配置地址
maven {
url '上面复制的地址'
}
在主App的module中添加
compile 'com.puxiaoshuai:ToastMessage:0.1.0'
不起效果,就加
compile 'com.puxiaoshuai:ToastMessage:0.1.0@arr'
遇到的问题-----------------分割线-----------------------------------------
-
Error while merging dex archives(Program type already present )
com.android.tools.r8.errors.CompilationError: Program type already present: puxiaoshuai.com.hellolibrary.BuildConfig
该问题是自己创建的module跟项目名重名。尽管有大小写区分,但是包名是一致的,所以导致错误
-
gradlew clean时,提示仓库名不匹配
原因配置时 repoName 应该与自己bintray的仓库名一直,不然找不到。
网友评论