Ok, how do I publish this?
There are some ways to distribute an android library, so right here’s a few them
This might be the simplest one. You check in along with your Github account, add your repo, and you’re set!
jCenter() is a central repository hosted by Bintray, and with a view to publish your library there, you’ll should create an account on bintray. If you’re planning on publishing an open-source library, you may join a free open supply account right here. Otherwise, you may look into their paid plans for internet hosting non-public repositories.
Add a brand new repository to host your undertaking
Your new repository ought to now seem in your account. Open it, and add a brand new bundle
Create a bundle inside your new repository
Get an API key
Next, you want to get an API key to make use of it to push your library to the repository from Android Studio. Go to https://bintray.com/profile/edit, and select API Key from the left menu.
You’re virtually there! All you want to do now could be add some Gradle scripts to your library
Add your username and API key to your native.properties file
native.properties file (ensure that it’s added to your
.gitignore file!), and add the next:
Add the Bintray and Maven Gradle plugins to your undertaking
In your app-level
construct.gradle file, add these dependencies to your buildscript
Create the script for importing your library bundle to Bintray
Thanks to Gradle’s modularity, we will extract all of the scripts required to do that and put them in a single file. Inside your library bundle, create a brand new file known as
publish.gradle and paste this code in it.
Then in your project-level
construct.gradle file, add the next line to the underside:
apply from: 'publish.gradle'
The solely issues you want to care about on this file are these three traces:
groupId, artifactId, model. Together, they make up the hyperlink to your library, so customers can obtain it by doing this:
Upload to Bintray
The final thing left to do is to publish your shiny new library to bintray so others can use it. So construct your undertaking, fireplace up the terminal in Android Studio and sort down this command:
If you’re on Windows
If you’re on Linux/Mac
That’s it! Your library is now printed and different individuals can use it. I hope you discovered this convenient. You can see the code in motion in my library right here.