1. 創建項目,toastlibrary就是我們需要上傳到JCenter的庫
1.png
2. 引入上傳插件
項目根目錄的build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'com.novoda:bintray-release:0.4.0'
}
module中的build.gradle
apply plugin: 'maven'
apply plugin: 'com.novoda.bintray-release'
..............
..............
publish {
userOrg = 'zhujian19890805' //bintray用戶賬號
groupId = 'com.jzhu.io.toastlibrary' //library的唯一id,用包名即可
artifactId = 'toastlibrary' //倉庫名,最后生成的可依賴:compile 'com.jzhu.io.toastlibrary:toastlibrary:1.0.0'
version = '1.0.0' //版本號
description = 'custom toast' //描述
website = "https://github.com/zhujian1989/freetoast" //github地址
}
3. 創建bintray賬號
官網:https://bintray.com/
注冊流程就不多說了
4. bintray中操作
a.點擊 add New Repository 添加倉庫
6.png
b.創建倉庫,完成后如圖
7.png
8.png
c.查看api key
10.png
12.png
4. 上傳到JCenter,打開as的Terminal,執行如下命令,顯示suc,恭喜你
./gradlew clean build bintrayUpload
-PbintrayUser=你的賬號
-PbintrayKey=你的api key
-PdryRun=false
5. bintray中查看,并點擊 Add to JCenter發布
3.png
13.png

6. 如何使用
發布到JCenter中,在未通過審核前
項目根目錄的build.gradle
repositories {
jcenter()
maven{ url 'https://dl.bintray.com/zhujian19890805/maven'}
}
dependencies {
compile 'com.jzhu.io.toastlibrary:toastlibrary:1.0.0'
}
當項目通過審核過后會有通知,就可以愉快的使用了
