I have created a new module in Android Studio, and wrote my code in it. Now i want to upload it on github and get a gradle dependency which others can include in their project and use my library. How can i get it?
PS. I know how to use git, i just don't know how to upload just the library module and get the gradle dependency.
The esiest way is to create a git repository in Github and upload it there.
After that, you can use jitpack.io to use it with gradle.
The long old way, it is to create a Bintray project, and deploy it at MavenCentral and/or JCentre.
What do you need to do is upload your project to Bintray or sonatype
See here a good tutorial:
how-to-upload-library-to-jcenter-maven-central-as-dependency
Related
I have an Android project in which I have added Android library as a module and use it within the project. Android library module is part of the project.
what I want to do is, remove the Android library from the project and host it in Github and use the Android library as a dependency in Android project.
Is that possible, if so how can I achieve that please.
If you think I should not be creating a Android library within the Android project I want to use it in, and create Android library as a separate project do let me know as well. (But this was it is a bit hard to debug I think)
Your suggestion and advice will be very helpful
Thanks
R
You need to publish your Library to Github Packages in order to use it as a dependency.
Follow this tutorial to do it.
Update 1
Another way to do that is by using JitPack. You just need to publish your library into Github repository and then you create a dependency using JitPack from that repo.
I have around 49 android apps. All of them have a reference to one library project. Till now, I have been developing on eclipse. Now, I am moving to Android Studio. What's the way to reference a library project in Android Studio?
I tried the answer mentioned in
How to include library projects in Android Studio that are stored in a separate git repository?
This actually copies the library project within the app project. So, If i change anything in the library, it will not be reflected in 48 other apps.
How about creating a library project, then adding it to Bintray and including in your projects dependencies?
Follow this guide up to the point where you'll be able to include your library like this:
repositories {
maven {
url 'https://dl.bintray.com/$DEVELOPER$/maven/'
}
}
...
dependencies {
compile 'groupId:artefact:0.0.1'
}
Then consider sharing it on jCenter / mavenCentral.
Beware, that sharing code privately on Bintray is not free. This solution would be really optimal for opensource library though
you can have your library code in git and add it to your application projects as a sub module. so if you modify the library from one project you can push the changes to the library git and then from other application you can pull those changes. it would be better to keep separate branch of library for each application so as not to conflict with the usage on modification.
i have explained the steps to add a git library as a sub module in here: Android Studio, how to add my own git repository as a library project(sub module)?
I have been developing an application and I have came across to add the following dependency in the gradle.
dependencies {
compile 'com.github.PhilJay:MPAndroidChart:v2.1.6'
}
I wonder how should I trust the github source code owner? What if source code owner deletes the source code?
Will my project fail if it could not able to find the github path?
Since the library is using jitpack and jitpack uses a mechanism of cache if the user removes the project the aar or jar will be reachable until the jitpack cache is valid. And at your local gradle also saves a copy of the library.
But your question is more that that, and yes, you should trust in the open source community. If you dont want to trust in Phil Jay work.. you can allways fork the project and use the code from your fork or just download the aar and import it directly from your project.
If you want to save a copy of the library you can download it directly from here: https://jitpack.io/com/github/PhilJay/MPAndroidChart/v2.1.6/MPAndroidChart-v2.1.6.aar
No when you first build the grandle, Android Studio look for it in the web, download and compile to use it. If you get it while it's active, you will have it in local drive, and can use it no matter if the source is erased.
I would like to open source a library project that I am working on in android studio (hosted on GitHub) and allow others to include the project as a dependency.
Example:
dependencies {
compile 'com.test:myproject:1.0'
}
I've done some research, and have only discovered how to create a module and import it locally within my project. Does anyone know the necessary steps to take to achieve what I want?
Basicly you can publish your app on a public repository like maven or jCenter. The easiest way is to published on bintray, it's free for open source public library. You can use the following library to help you
Also, look into jitpack.io. It is easily the quickest way for getting a JVM projects up and ready especially if you're already using Github. Here's the extra docs for it as well.
I know that people use GitHub to deploy Maven artifacts (in a new branch) but since we are using Gradle I would like to know if there is a simple way of handling those dependecies as well?
We have different little projects that are independent but used by our main project and we want to manage those dependencies without including them locally.
Thank you.
There is an unofficial gradle plugin called Gradle Git Repo plugin that claims to do what you're looking for. Note however, that I did not play with it myself to verify that it works.
You could use JitPack to include your GitHub projects as dependencies. The idea is that JitPack provides a Maven repository where each package comes from a GitHub project.
It doesn't require that you upload files so it's quite easy to use. Instead when you request a file it builds it from source code.
There are two requirements to start using:
1. You need to have a build file in your project (Gradle or Maven)
2. You shoud create a GitHub release so that your project gets a version