Copyright notice: This article is an original article by Shan Cancan, non-commercial free reprint – keep the signature – indicate the source, thank you.

Recently when I was organizing a project, I wanted to upload it to Jcenter, so I could introduce it in a single line of code. On the Internet to find, however, some methods on the Internet is too troublesome, so write this article will be sad to write down the course, let you old drivers less detour, fast release. More recently, bintray has been changed, so now many people upload their code successfully and find that there is no Add to Jcenter button.

Below I take you step by step towards the road of Daniel, towards happiness towards a well-off society. In this paper, we plan to use the bintray-release plug-in recommended by Hongyang. I personally feel it is much more convenient than gradle-Bintray-Plugin.

Step 1: Apply for a Bintray account and get the information you need (very important, watch the steps carefully)

Why register this account? Jcenter () is a warehouse owned by Bintray.

That’s why you guys need a Bintray account. Register at bintray.com/



At this point, you’ve done the wrong thing, unless you’re an enterprise user or you’re waiting 30 days. Why? Look at the picture and speak!

The personal free version can be registered at bintray.com/signup/oss

Do not use QQ, 163, etc. If you use Github to log in quickly, also pay attention to email problems.

Obtain information: After login, click the user name in the upper right corner of the homepage to enter the personal homepage, and then click Edit Profile under the user name to enter the personal information editing page. Next, click the last API Key in the list on the left of the page to save it and use it later. To copy your API Key, click the copy button indicated by the arrow on the far right:

Step 2: Introduce bintray-Release

You should have a project to upload first. Here I simulate a simple project using one of my Android libraries. Tobebetter is an Android library that primarily houses a digital clock, which we will now upload to JCenter.

Project build.gralde introduction

The build in your project. Add bintray gradle – release the classpath, pay attention to is the project build. Gradle, not the module, MyApplication3 / build gradle.

The classpath 'com. Novoda: bintray - release: 0.3.4'Copy the code

Configure the build.gralde for the moudle to be uploaded

To you want to upload the module, in view of the article first figure namely MyApplication3 / tobebetter/build. Gradle.

apply plugin: Publish {userOrg = 'shantecnology'//bintray.com username groupId = Halloandroid '// jCenter path artifactId = 'tobeBetter '// project name publishVersion = '1.0.0'// version desc = 'this is for The test '/ / description, not important website =' https://github.com/shanlovana/tobebetter 'important} / / website,, had better notCopy the code

You can write according to the picture, the details are annotated, assuming that you write according to the above, and upload successfully, then your project will be introduced in the following way:

The compile 'com. Halloandroid: tobebetter: 1.0.0Copy the code

Once the above configuration is complete, we are ready to upload.

Upload the code to Bintray

The upload is simple and can be done in the Terminal panel of Android Studio by executing the following code:

Windows:

  gradlew clean build bintrayUpload 
 -PbintrayUser=shantecnology  
 -PbintrayKey=xxxxxxxxxxxxxxxxxxxxxx 
 -PdryRun=false
Copy the code

Mac:

 ./gradlew clean build bintrayUpload 
 -PbintrayUser=shantecnology  
 -PbintrayKey=xxxxxxxxxxxxxxxxxxxxxx 
 -PdryRun=false
Copy the code

User is the user name, key is the Api key we just saw, dryRun is a configuration parameter, and when true, all links run but no uploads.

Then wait, when the run and upload is complete, see BUILD SUCCESSFUL no problem, if there is a problem, according to the log check.

Upload to complete here, is not very fast!

Enter our upload space to see our project, such as the address I just uploaded: bintray.com/shantecnolo…

Your upload address is: bintray.com/ your username /maven



Submit a short description in English, try not to use Chinese.

That’s the end of the tutorial, but you can’t use it right now. You have to wait for the Bintray people to approve it, and it will send you an in-site Message for about two hours, and the Add to Jcenter button will disappear.

Matters needing attention:

Garbled code problem:

If there is Chinese in the comment, it may appear: non-mappable character encoding GBK

Build. Gradle = build.gradle

allprojects {
tasks.withType(Javadoc) {
    options{
        encoding "UTF-8"
        charSet 'UTF-8'
        links "http://docs.oracle.com/javase/7/docs/api"
    }
  }
}
Copy the code

2, in fact, I think we can completely change the Chinese notes into English, after all, we are going to be big men, you know! Baidu Translate, Bing Translate…

Version update

After we finish uploading, we will definitely involve the issue of update, so How to update?

Publish {userOrg = 'shantecnology'//bintray.com user name groupId = 'com.halloandroid'// path on jcenter artifactId = 'tobeBetter' publishVersion = '2.0.0' publishVersion = 'this is for test' = 'https://github.com/shanlovana/tobebetter' is not important website / / site, the best you have, not important}Copy the code

Most of them do not need to be touched, just modify the version number, after the modification, execute the upload code, after the upload is complete, click the button below. Update review is faster, just wait a minute.

This is the end of the tutorial, is not so easy! ???