First, write in front
Since using Android Studio, it has been fascinated by its unique way of relying: Compile ' com.android.support:appcompat-v7:25.0.1 ', since it has Hemp no longer has to worry about relying on third-party jar packages. And, if you write an open source library is a kind of experience, this is the LI (the Kingdom) (force) (God) people () Ah!
And all the way, you will find that if you want to publish your open source library to the official Bintray/jcenter is not easy, so first to explore the Internet, simple, difficult, multifarious, all (wrong) face (person) with (son) prepared (brother)!
Have to sigh, learning technology itself is not difficult, difficult to achieve a goal of a variety of ways, and various ways uneven, to novice bring great confusion. But there is no way, who call you a beginner, you can do, can only be a step in the toss themselves.
Online posts really many Ah, a variety of, registered account has problems, the writing process has problems, version inconsistencies have problems, install a problem .... Everyone's steps are inconsistent, so it is difficult to get a really right thing, cause you wrong, but do not know where the wrong, this is the most uncomfortable, well, the programmer overtime is because these details of the cause of the incident, so, we want meticulous!!!
In fact, to a comprehensive analysis, the landlord is afraid, deep fear of a small detail and go to fraught, but the landlord is also a lot of time to deal with, so sincerely hope to bring you a little help, insufficient place, but also please you shoot bricks ~
Not much nonsense, go straight to the point, here take me a random open source library to do the processing, git address: Https://github.com/nanchen2251/CalendarView, this is a cool Calendar selection control (support left and right sliding, lunar, Holiday display, etc.)
Demo Effect:
Second, registered account
1) First you have the key to open the door, first go to https://bintray.com register an account (you can also use a third-party login github,google, but the landlord found that if your GitHub has not been successful, the original email address can not use QQ mailbox);
2) Registration
3) Submit Registration information
4) Create an organization and warehouse
5) Fill in the basic information
Third, the configuration project related
1) Add Build.grald in Project
Classpath ' com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4 '
' com.github.dcendents:android-maven-gradle-plugin:1.4.1 '
2) module inside add
// Configuration plugin Apply plugin: ' Com.github.dcendents.android-maven 'com.jfrog.bintray '
3) Add the following code to the module's build.gradle, note the comment
Version = "1.0.7"//This is the version number that must be filled indef siteurl = ' Https://github.com/nanchen2251/CalendarView '//home page of the projectdef giturl = ' Https://github.com/nanchen2251/CalendarView '//the URL of the Git repositoryGroup= "Com.nanchen.calendarview"//here is GroupID, must fill in the general fill your unique package nameInstall {repositories.maveninstaller {//This generates pom.xml with proper parametersPom {Project {packaging' AAR '//project Description, copy my words, here need to change. Name ' A view with the lunar calendar '//Project DescriptionURL SiteURL//Software Open Source Agreement, now generally is Apache License2.0 bar, copy my, here do not need to modify. Licenses {license {name' The Apache software License, Version 2.0 'URL' Http://www.apache.org/licenses/LICENSE-2.0.txt ' } } //fill in the developer basic information, copy my, here need to change. Developers {developer {ID' Nanchen '//your company's IDName ' nanchen2251 '//your user nameemail ' [Email protected] '//your e-mail } } //SCM, copy My, there is no need to modify. SCM {Connection Giturl developerconnection Giturl URL SiteURL} }}}//generate a task for the jar package, no modification is required. task Sourcesjar (Type:jar) {from android.sourceSets.main.java.srcDirs classifier= ' Sources '}//generate Javadoc jar, no modification requiredtask Javadoc (type:javadoc) {options.encoding= "UTF-8"Source=android.sourceSets.main.java.srcDirs classpath+=Project.files (Android.getbootclasspath (). Join (File.pathseparator))}task Javadocjar (Type:jar, DependsOn: Javadoc) {classifier= ' Javadoc 'From Javadoc.destinationdir}//set the encoding format below, and note that if you do not set the GBK encoding mapping error may occur at Gradlew installJavadoc {options {encoding"UTF-8"CharSet' UTF-8 'authortrueversiontruelinks"Http://docs.oracle.com/javase/7/docs/api"title' A CalendarView support Lunar Calendar for Android '//Document title}}artifacts {//Archives JavadocjarArchives Sourcesjar}//Build Jar Packagetask Releasejar (type:copy) {from (' Build/intermediates/bundles/release ') into (‘.. /jar ') include (' Classes.jar ') Rename (' Classes.jar ', ' okgo-' + version + '. Jar ')}//here is the information to read the Bintray, we upload the project to GitHub when the Gradle file will be sent up,//so do not write the account password information directly here, written in local.properties, here dynamic read. Properties Properties =NewProperties () properties.load (Project.rootProject.file (' Local.properties '). Newdatainputstream ()) Bintray {//read the Bintray.user inside the local.properties fileuser = Properties.getproperty ("Bintray.user") //read the Bintray.apikey inside the local.properties fileKey = Properties.getproperty ("Bintray.apikey") Configurations= [' Archives '] Pkg {userorg= "Nanchen"//Publish to Jcenter organization, note that the new version of Bintray is required to be created manuallyRepo = "maven"//Publish to the warehouse name on Jcenter, note that the new version of Bintray is created manually//name of the project published on BintrayName = "Calendarview-library"Websiteurl=SiteURL Vcsurl=Giturl Licenses= ["Apache-2.0"] Publish=true //whether it is a public project }}
4) Some instructions
Note: The above userorg is the organization (organization) ID (created above), many posts do not have this or write the user name, the new version to use the organization name you created, otherwise failed; Repo is the name of the warehouse (repository), I was looking at the post here is not clear how can not succeed.
If you forget, you can view this, organize the corresponding ID, the warehouse corresponds to the repo, the project corresponds to the name above.
5) If not unexpected, you can now operate the terminal workspace input Gradlew install in the command line of Android Studio;
6) If you succeed, you can see your AAR file below the module's build/outputs
7) At this point you can enter Gradlew bintrayupload via the command line to upload to the Bintray warehouse.
8) Everything is ready, you can now see your library in Bintray, and finally click Add to Jcenter apply for review (generally 2-3 hours can be audited)
9) Send Request
Fill in your groupid, send directly, and you'll start a packaged version of the request,
In a few hours, through the jcenter side of the audit will be on the Bintray to receive jcenter side of the consent message to remind.
Congratulations, your class library has been uploaded to Jcenter successfully! Everyone can use your class library.
10) Subsequent updates to the Open source Library
After we upload, if found in the class library a bug in the class library, which involves updating the problem, then how to update it?
You only need to modify the code after the local Build.gradle version number, press the above action, execute Gradlew install,gradlew bintrayupload, go to Bintray Click on the stage snapshots on Oss.jfrog.org "also sends a request, not a few minutes, can be used, upgrade, unlike the first submission, very fast. Immediately you can update the reference version number on GitHub, instantly mood Shuangshuang.
V. Some of the pits that have been trampled
1)Lint found errors in the project
The Lint check is turned on by default, Lint checks for syntax errors in the project and cannot continue if it is not passed. Just add the following code to the Module's build.gradle:
Android { lintoptions { false }}
2) Coding issues
Perhaps you will encounter this:
Under Windows Javadoc The default is System encoding, and Windows is GBK encoding. Therefore, once the Java file appears in Chinese comments will be an error, indicating the GBK encoding cannot be mapped.
task Javadoc (type:javadoc) { = "Utf-8"}
If not, use the way I did.
// set the encoding format below, and note that if you do not set the GBK encoding mapping error may occur at Gradlew install Javadoc { options { "UTF-8" ' UTF-8 ' true true "Http://docs.oracle.com/javase/7/docs/api" ' A calendarview support Lunar Calendar For Android ' // document title }}
"Stepping on the pit shorthand" comprehensive analysis open Source Library package release to Bintray/jcenter whole process (new), make open source easier ~