轉自:http://blog.csdn.net/Small_Lee/article/details/52328613
概述
首先給出gradlew命令
gradlew clean build bintrayUpload -PbintrayUser=用戶名 -PbintrayKey=xxxxxxxxxxx -PdryRun=false
最近在將寫好的庫發布到jCenter的一個步驟中,出現了一個錯,錯誤信息如下:
20160826150440995.png
大概意思是說產生JavaDoc的時候出錯了,經過網上查找,解決辦法如下:
allprojects {
repositories {
jcenter()
}
//加上這些
tasks.withType(Javadoc) {
options {
encoding "UTF-8"
charSet 'UTF-8'
links "http://docs.oracle.com/javase/7/docs/api/"
}
}
}
之后又遇到一個錯:
* What went wrong:
Execution failed for task ':dashview:bintrayUpload'.
> Could not create version 'v1.0.0': HTTP/1.1 401 Unauthorized [message:This resource requires authentication]
錯誤的大概意思是資源需要驗證,經過一番嘗試,解決辦法如下:
publish {
userOrg = 'smalllee'//bintray.com用戶名
groupId = 'com.robert'//jcenter上的路徑
artifactId = 'dashview'//項目名稱
.....
}
這里的artifactId是你之前最初在bintary的maven中創建的那個package的名字,這里需要對應上,否則會上傳失敗 :
20160829101102837.png
有些朋友有時也可能會遇到下面這個錯:
* What went wrong:
Execution failed for task ':dashview:bintrayUpload'.
> Could not create package 'smalllee/maven/dashview': HTTP/1.1 404 Not Found [message:Repo 'maven' was not found]
出這個錯的原因是你創建倉庫的時候名稱寫的不是maven,也就是說你創建倉庫的時候應該按照下面的方式,名字必須指定為maven。
20160829100845780.png
上面的錯解決完以后,感覺離成功已經不遠了,執行gradlew命令后又遇到一個錯:
Execution failed for task ':flybanner:bintrayUpload'.
> Could not upload to 'https://api.bintray.com/content/SmallLee/maven/flybanner/1.0.0/com/lxn/flybanner/1.0.0/flybanner-1.0.0-sources.jar': HTTP/1.1 404 Not Found [message:Subject 'SmallLee' was not found]
最后發現,出這個錯的原因是因為一次只能上傳一個library,如果你此時在其他library里面也進行了上傳配置的話,就會報上面的錯,這點一定要注意。
解決完上面的錯誤以后,就上傳成功了,我們可以看到上傳的項目。
20160829103651138.png
20160829105418021.png
相關文章
Android 快速發布開源項目到jcenter
Android拓展系列(12)--使用Gradle發布aar項目到JCenter倉庫
使用Gradle發布Android開源項目到JCenter
使用Gradle發布項目到JCenter倉庫
gradle-publish