1. 程式人生 > >Make an android custom view, publish and open source.

Make an android custom view, publish and open source.

Publish your library:

After finish pushing your project to GitHub, there is the last step to get done: publish it so that developers can just add dependency

dependencies {
...
compile 'com.dualcores.swagpoints:swagpoints:1.0.2'
}

to use you project. Here we go:

1. Sign-up or sign-in at JFrog Bintray
.

2. Go to profile page to create a repository, package, and version:

The repository is the place to host your several projects. You can choose any repository name whatever you want, it doesn’t matter for other developers.

Inside the new repository, you can create a package, that is place to host your project. Your project also can import from GitHub.

For each package, you can create several versions, again, you can choose whatever name you want, not restricted to the traditional version number major.minor.patch rule.

3. Generate and upload the aar files:

Open you library module gradle file, add the following code snippet to buttom of module build.gradle

file:

// or use the remote copy to keep update with latest changes
apply from: 'https://raw.githubusercontent.com/blundell/release-android-library/master/android-release-aar.gradle'

and JCenter configuration:

ext {
PUBLISH_GROUP_ID = 'com.dualcores.swagpoints'
PUBLISH_ARTIFACT_ID = 'swagpoints'
PUBLISH_VERSION = '1.0.0'
}
The two place you have to insert code in library module build.gradle file

then, sync your project and open your terminal, go to your project root path, execute the command:

./gradlew clean build generateRelease

If success, you will see the result in you terminal and you can upload the zip file from PROJECT_ROOT/library/build/release/1.0.0/:

4. Add to JCenter:

Go back to your project page in bintray, there will be a Add to JCenter button in right-hand column, just click it to fill out a message and wait to be accepted. It takes hours or several days to be accepted, just be patient. This step is required so that to make your project downloadable and discoverable by gradle dependencies.

5. Project is accepted and test if everything is all right:

You will receive an email to inform you that your Add to JCenter request is accepted.

Once it is accepted, test if gradle dependency works well by adding the dependency to sample module and sync. If it builds successfully, congratulation!!!! You’ve done. Good job~

compile 'com.dualcores.swagpoints:swagpoints:1.0.0'
The version may change when you try to use, just check my GitHub to get the latest version.