{"id":1855,"date":"2023-03-29T22:04:59","date_gmt":"2023-03-29T14:04:59","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1855"},"modified":"2023-04-22T09:08:48","modified_gmt":"2023-04-22T01:08:48","slug":"android-upload-project-to-jcenter-simple-steps","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/29\/android-upload-project-to-jcenter-simple-steps\/","title":{"rendered":"Android\u4e0a\u4f20\u9879\u76ee\u5230JCenter\u7b80\u5355\u6b65\u9aa4"},"content":{"rendered":"<h2>\u57fa\u672c\u6b65\u9aa4<\/h2>\n<h3>\u521b\u5efaProject\uff0c\u521b\u5efaAndroid Library<\/h3>\n<h3>\u6ce8\u518cbintray.com \u83b7\u5f97API Key<\/h3>\n<p><!-- more --><\/p>\n<h3>\u9879\u76eebuild.gradle\u914d\u7f6e<\/h3>\n<p>\u5728Project\u7684<code>build.gradle<\/code>\u4e0b\u7684<code>dependencies<\/code>\u6dfb\u52a0<code>classpath &#039;com.novoda:bintray-release:0.5.0&#039;<\/code><\/p>\n<pre><code class=\"language-java\">buildscript {\n    repositories {\n        jcenter()\n    }\n    dependencies {\n        \/\/https:\/\/github.com\/novoda\/bintray-release\n        classpath &#039;com.novoda:bintray-release:&lt;latest-version&gt;&#039;\n    }\n}<\/code><\/pre>\n<h3>\u5e93\u6a21\u5757build.gradle\u914d\u7f6e<\/h3>\n<p>\u5728library\u7684<code>build.gradle<\/code>\u4e0b\u6dfb\u52a0<code>apply plugin: &#039;com.novoda.bintray-release&#039;<\/code>\u4ee5\u53capublish<\/p>\n<pre><code class=\"language-java\">apply plugin: &#039;com.android.library&#039;\napply plugin: &#039;com.novoda.bintray-release&#039;  \/\/\u4e0a\u4f20\u5230JCenter\u5de5\u5177\n\nandroid {\n  \/\/...\n}\n\ndependencies {\n  \/\/..\n}\n\npublish {\n  userOrg = &#039;yezhou&#039;    \/\/bintray.com\u7528\u6237\u540d\n  groupId = &#039;cn.appblog&#039;    \/\/jcenter\u4e0a\u7684\u8def\u5f84\n  artifactId = &#039;testLib&#039;    \/\/\u81ea\u5df1\u7684maven\u4e0a\u6dfb\u52a0\u7684\u5305\u540d\n  publishVersion = &#039;0.0.1&#039;    \/\/\u7248\u672c\u53f7\n  desc = &#039;desc...&#039;    \/\/\u63cf\u8ff0\n  website = &#039;http:\/\/www.appblog.cn&#039;    \/\/\u7f51\u7ad9\uff0c\u4e0d\u91cd\u8981\n}<\/code><\/pre>\n<h3>\u547d\u4ee4\u884c\u4e0a\u4f20<\/h3>\n<p>Windows\uff1a<\/p>\n<pre><code class=\"language-bash\">gradlew clean build bintrayUpload -PbintrayUser=username -PbintrayKey=APIKey -PdryRun=false<\/code><\/pre>\n<p>Mac\uff1a<\/p>\n<pre><code class=\"language-bash\">.\/gradlew clean build bintrayUpload -PbintrayUser=username -PbintrayKey=APIKey -PdryRun=false<\/code><\/pre>\n<p>\u5c06\u547d\u4ee4\u884c\u4e2d\u7684username\u6362\u6210Bintray\u7684\u7528\u6237\u540d\uff0cAPIKey\u6362\u6210\u7b2c\u4e8c\u6b65\u83b7\u5f97\u7684key<\/p>\n<h3>\u5728Bintray\u4e0aAdd to JCenter<\/h3>\n<h3>\u5feb\u7167<\/h3>\n<p>Snapshot builds from develop are automatically deployed to a repository that is not synced with JCenter. To consume a snapshot build add an additional maven repo as follows:<\/p>\n<pre><code class=\"language-java\">repositories {\n    maven {\n        url &#039;https:\/\/dl.bintray.com\/novoda-oss\/snapshots\/&#039;\n    }\n}<\/code><\/pre>\n<h2>\u9047\u5230\u7684\u95ee\u9898<\/h2>\n<p>\uff081\uff09\u5728<code>Add to JCenter<\/code>\u7684\u65f6\u5019\u63d0\u793a<code>Empty packages are not allowed in JCenter.<\/code>\u65e0\u6cd5\u63d0\u4ea4\u9879\u76ee<\/p>\n<p>\u67e5\u770b<code>Files<\/code>\u7684\u786e\u662f\u6ca1\u6709\u4efb\u4f55\u6587\u4ef6<code>There are no files yet for this package.<\/code><br \/>\n\u67e5\u770b\u547d\u4ee4\u884c\uff1a<code>:bintrayUpload: Could not find publication: release.<\/code><\/p>\n<p>\u67e5\u770b\u65e5\u5fd7\uff0c\u63d0\u793a<code>bintray-release<\/code>\u7248\u672c\u548c<code>gradle<\/code>\u7248\u672c\u4e0d\u7edf\u4e00<\/p>\n<p>\uff082\uff09\u9047\u5230\u4e2d\u6587\u6ce8\u91ca\u4e71\u7801\u95ee\u9898<\/p>\n<pre><code>\/\/\u9519\u8bef\u65e5\u5fd7\u7c7b\u4f3c\u8fd9\u6837\nD:\\Jcenter\\utils\\src\\main\\java\\cn\\appblog\\utils\\log\\JsonLog.java:35: \u9519\u8bef: \u7f16\u7801GBK\u7684\u4e0d\u53ef\u6620\u5c04\u5b57\u7b26 Log.d(TAG, &quot;\u923a? &quot; + line);<\/code><\/pre>\n<p>\u5728Project\u4e0b\u7684<code>build.gradle<\/code>\u4e0b\u6dfb\u52a0<\/p>\n<pre><code class=\"language-java\">allprojects {\n    repositories {\n        jcenter()\n    }\n\n    allprojects {\n        tasks.withType(JavaCompile) {    \/\/\u8bbe\u7f6e\u5168\u5c40\u7f16\u7801\n            options.encoding = &quot;UTF-8&quot;\n        }\n        tasks.withType(Javadoc) {    \/\/\u8bbe\u7f6e\u6587\u6863\u7f16\u7801\n            options {\n                encoding &quot;UTF-8&quot;\n                charSet &#039;UTF-8&#039;\n                links &quot;http:\/\/docs.oracle.com\/javase\/7\/docs\/api&quot;\n            }\n        }\n    }\n}<\/code><\/pre>\n<p>\uff083\uff09\u6210\u529fAdd to JCenter \u4f46\u662f\u4e0d\u80fd\u62c9\u53d6<\/p>\n<pre><code>Error:(32, 12) Failed to resolve: cn.appblog:utils:0.0.1<\/code><\/pre>\n<p>\u53ef\u80fd\u662f\u5ba1\u6838\u95ee\u9898\uff0c\u4ee5\u6536\u5230<code>Bintray<\/code>\u7684\u7ad9\u5185\u4fe1\u4e3a\u51c6<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u57fa\u672c\u6b65\u9aa4 \u521b\u5efaProject\uff0c\u521b\u5efaAndroid Library \u6ce8\u518cbintray.com \u83b7\u5f97API Ke [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[202],"tags":[477],"class_list":["post-1855","post","type-post","status-publish","format-standard","hentry","category-android-build","tag-jcenter"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1855","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1855"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1855\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1855"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1855"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1855"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}