background

Recently, I wrote a component and wanted to upload it to Jcenter for everyone to use. It was the first time to upload it, so I took some detours. Now I will sort it out for friends who need to learn.

Data preparation

  1. First of all, we need an account of Bintary. I myself fell into the pit just at this step. Never! Never! Do not go to the homepage of the official website to register, which is the organization account (there is no upload Jcenter behind the organization account that we need), we will register through the following address. Personal account registration address: bintray.com/signup/oss If you have a GitHub or Google account, you can log in directly, but the registered email must be a foreign email.
  2. After registering, we need to confirm the login email. After logging in, we need to create a Repository first.




    Add New Repository

    After creation, we need to fill in some information, this we can according to their own needs.




    RepositoryInfo

  3. Create a Package corresponding to the project



    Add New Package

    After the creation is complete, fill in the relevant information:



    PackageInfo

    Just fill in something marked with an asterisk,Do not write Name casually, as much as possible related to the lib you are uploading, will be used later.

    Okay, so that’s it for now with our Bintray we’re ready to upload.

Upload the Android Library

After checking the information, I found a Gradle plug-in which can be directly uploaded to the corresponding Bintary through configuration. The GitHub source address is posted below for those interested in studying: Bintray-release. We will not expand it here and directly explain how to use it. Build. Gradle > build. Gradle > build.

classpath 'com.novoda:bintray-release:+'
Copy the code

2. Add references to the library moudel

apply plugin: 'com.novoda.bintray-release'
Copy the code

3. See from other blogs if you have Chinese comments in your open source library, you can add the following code

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

4. Ignore error messages detected by Lint

android {
 lintOptions {
        abortOnError false
    }
}
Copy the code

5. Upload the open source library parameters

Publish {userOrg = 'XXXXX' //bintray registered user name groupId = 'com.xxx. XXX '//compile reference to the first part of groupId, ArtifactId = 'XXXXX' //compile reference to the second part of the project Name, this needs to be the same as the Name of the package we created earlier, Do not upload failed publishVersion = '1.0.0 / quote/compile part 3 version number desc =' This is a library '/ / describe literally write website =' / / web pages of the project, GitHub address to write source code}Copy the code

6. Compiling Windows from the command line:

gradlew clean build bintrayUpload -PbintrayUser=BINTRAY_USERNAME -PbintrayKey=BINTRAY_KEY -PdryRun=false
Copy the code

OS x

./gradlew clean build bintrayUpload -PbintrayUser=BINTRAY_USERNAME -PbintrayKey=BINTRAY_KEY -PdryRun=false
Copy the code

BINTRAY_USERNAME is changed to the user name registered with Bintray, and BINTRAY_KEY is changed to its own APIKEY.





UserInfo


The username is the one up there, the APIKey and we can see it by just clicking on the APIKey and then we can see it on Bintray when we’re done running it.

Publish to JCenter platform





JCenter.png


As shown in the picture, all we need to do is click Add to JCenter and it will be approved in a few hours.

Open source library dependencies

1. Use open source libraries that are still under review







image.png


Add your own address to the root directory build.gradle:







image.png


The compile 'com. XXX. XXX: 1.0.0'Copy the code

2. Direct reference of approved open source libraries:

The compile 'com. XXX. XXX: 1.0.0'Copy the code

conclusion

Well, it’s probably as simple as that. This article is also viewed and integrated from various blogs on the Internet. Thank you for your efforts.