- 快速发布 Android/Java Libs 到 Bintray
- Android studio 发布到bintray
- Android 开源库发布到jcenter(bintray-re
- Kotlin Library 发布 Bintray(JCente
- Android_发布library到mavenCentral(2
- 发布Android Library到Bintray、JCente
- Bintray+AndroidStudio发布项目到maven和
- AndroidStuio快速发布开源项目到Jcenter/Bin
- Android_上传library到Bintray并发布到JCe
- 使用Bintray发布library到JCenter中心
本文内容为:如何使用 BintrayRelease 插件快速发布一个 Android/Java Lib 到 Bintray Mavne,并引入 Project 使用的流程。
创建 Bintray 账户及 Maven 仓库
1、打开 Bintray 首页,点击 For an Open Source Account Sign Up Here,快速注册或者用第三方的账户登陆即可
![](https://img.haomeiwen.com/i3551539/0b9c11000b41d206.png)
2、个人页面点击 Add New Repository 创建一个 Mavne 仓库
![](https://img.haomeiwen.com/i3551539/a8b26b138bb988d4.png)
填写仓库信息,仓库名称记住,后面有用
![](https://img.haomeiwen.com/i3551539/b92f99b499a3cfb3.png)
3、获取 Bintray API Key
![](https://img.haomeiwen.com/i3551539/fb9aaa9f81783405.png)
点击箭头位置复制 API Key 后面有用
![](https://img.haomeiwen.com/i3551539/ea849b74a87c2677.png)
新建 lib 项目
1、正常新建一个 Android Project
2、创建一个 Android Lib Module
点击 File > New > New Module…,选择 Android Library > Next
![](https://img.haomeiwen.com/i3551539/70ed2c3b2edf6435.png)
填入你的 Libraray name
![](https://img.haomeiwen.com/i3551539/5a410c9131960222.png)
配置 bintrayrelease 插件
1、在 Project 的 build.gradle 文件中添加快速发布插件地址
buildscript {
...
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
// 快速发布插件
// https://github.com/StefMa/bintray-release
classpath "guru.stefma.bintrayrelease:bintrayrelease:1.1.2"
}
}
2、在 Lib Moudle (非 app Moudle 注意区分)的 build.gradle 文件中尾部追加如下内容
// 快速发布插件
apply plugin: "guru.stefma.bintrayrelease"
// lib version
version = "1.0.2"
// 组名,一般同包名
group = "cc.skyrin"
// 组件信息配置
androidArtifact {
// lib 组件 id
artifactId = "crashcatch"
}
// 如上配置之后,将来引用的 path = group:artifactId:version
// 即 'cc.skyrin:crashcatch:1.0.2'
// 发布参数配置
publish {
// bintray 用户名
userOrg = 'skyrin'
// bintray repository 名称,填入在 bintray 创建的仓库名
repoName = 'maven'
// 不执行 --dry-run
dryRun = false
// lib 描述
desc = 'a usefull crash catcher'
// lib 开源地址,不重要
website= 'https://github.com'
}
发布 Lib 到 Bintray Maven
1、打开 Terminal 输入如下命令,参数 PbintrayUser 的值为你的 Bintray 用户名,PbintrayKey 为之前获取的 Bintray API Key
./gradlew clean build bintrayUpload -PbintrayUser=skyrin -PbintrayKey=45c86666666666666666666666666666666666
2、如果顺利的话控制台如下所示,表示提交成功,如果出现异常可参照文章附录异常解决
![](https://img.haomeiwen.com/i3551539/0624974cc29d64c1.png)
在项目中引用
1、获取你的 Maven URL 并配置在需要使用的 Project 的 build.gradle 中
![](https://img.haomeiwen.com/i3551539/57e37056d16fbc96.png)
![](https://img.haomeiwen.com/i3551539/6c71de0f47c12af4.png)
allprojects {
repositories {
google()
jcenter()
// set up your bintray maven url
maven{url 'https://dl.bintray.com/skyrin/maven'}
}
}
2、 现在,可以在 Moudle 的 build.gradle 文件中添加依赖引用了
在 Bintray lib overview 中可以找到 maven、gradle、ivy 等配置引用方式
![](https://img.haomeiwen.com/i3551539/3553c72ccd60a82a.png)
添加引用到 build.gradle
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
...
implementation 'cc.skyrin:crashcatch:1.0.2'
}
发布过程常见错误
1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':crashcatch:bintrayUpload'.
> Could not upload to 'https://api.bintray.com/content/skyrin/maven/crashcatch/1.0.2/cc/skyrin/crashcatch/1.0.2/crashcatch-1.0.2.aar': HTTP/1.1 401 Unauthorized [message:This resource requires authentication]
检查 Bintray API Key 是否正确填入,=
后面不要带空格
1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':crashcatch:bintrayUpload'.
> Could not create package 'skyrin/mavens/crashcatch': HTTP/1.1 404 Not Found [message:Repo 'mavens' was not found]
检查 repoName 值是否和 Bintray Maven 仓库名称一致
1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':crashcatch:bintrayUpload'.
> Could not create package 'skyrincc/maven/crashcatch': HTTP/1.1 404 Not Found [message:Subject 'skyrincc' was not found]
检查 userOrg 值是否和 Bintray 用户名一致
如果上面三项都没问题的话,还是报 404 的错误,那么你可能需要科学上网发布。
网友评论