how to add my github library on android studio - android

I have a library such as LibraryOne and it's package name is com.gorkem.libraryone and i pushed library to github. When i use this library on other project, i want to access this library with dependecies like that: compile 'com.gorkem.libraryone' how they do that ? i can give many example such as compile 'com.google.code.gson:gson:2.3.1'. Are there any tutorials for this issiue ?

You just need to publish your library in JCenter or Maven.
Just follow this tutorial: https://www.virag.si/2015/01/publishing-gradle-android-library-to-jcenter/

https://jitpack.io must be what you want,use this and you can use
repositories {
maven {
url "https://jitpack.io"
}
}
dependencies {
compile 'com.gorkem.libraryone:v1.0.0'
}
You can refer to this project as example

Related

How to add something to gradle for other users?

How to add your own project to the gradle so other users can use it as a dependency? E.g.
dependencies {
compile 'com.myDomain.myProject-v1.0'
}
Create a library project. See this.
Push it to github. (Optional).
Publish it to bintray. See this tutorial.
Assuming that Some Other Folder is a gradle project you could add something like the following to your settings.gradle file:
include ':module1'
project(':module1').projectDir = new File(settingsDir, '../Project B/Module 1')
You have to push it in a maven repo, private or public.
You can check for example the bintray repo (jcenter)
You have to make it available in a repository. A very simple one is JitPack.
Host your lib on Github
Add JitPack in repositories
Add the dependency compile 'com.github.User:Repo:Tag'
Sample:
repositories {
...
maven { url 'https://jitpack.io' }
}
...
dependencies {
compile 'com.github.User:Repo:Tag'
}
Full documentation
Please you need to study about how to make library (module) on android studio, what is jcenter, what is maven center and also study about bintray.com.

Publish library for use it with Gradle

When you want to use a library from GitHub that the owner tells you to copy something like this to your dependencies and then you have access to it:
compile 'com.1gravity:android-rteditor:1.6.2'
How can I make this kind of URL for my library?
You have to publish to some public library repositories like jcenter, Maven Central or jitpack.

How to create a library on Github and use it through gradle dependencies in Android Studio

I want to create the library and have access to it through the Internet.
In Android Studio (via Gradle) dependency may be added in this way:
In build.gradle (Module app):
dependencies {
...
compile 'com.android.support:design:23.1.0'
compile 'com.squareup:otto:1.3.8'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.j256.ormlite:ormlite-core:4.48'
compile 'com.j256.ormlite:ormlite-android:4.48'
...
}
How can I add my own library in this way from github?
To achieve it you have some ways:
publish your library (artifact) in central maven or jcenter.
use a github repo and the jitpack plugin
use a private maven
The point 2. is very simple.
Just push your codein github and modify the gradle script in the project where you want to use it.
Just add this repo tp your build.gradle
repositories {
// ...
maven { url "https://jitpack.io" }
}
and the dependency:
dependencies {
compile 'com.github.User:Repo:Tag'
}
To publish a library in Central Maven or JCenter, it is very long to explain in an answer. Hovewer you can read these posts:
Publish on JCenter
Publish on Central Maven. Another blog for Central Maven
Refer Jitpack is best to import your project or libs from Github to gradle
For more information refer Gabriele Mariotti answer
For a quick solution, as the others have said JitPack is probably the way to go. However, if you want to make your library available to a wider audience you should probably add it to jcenter since this is set up by default in Android Studio now. (Previously it was Maven Central.)
This post gives a detailed walkthrough of how to do it. The following is a summary:
Create the Android library
Test to make sure the library is usable locally
Publish the library on Bintray
Add the library to Jcenter
Then all people will have to do to use your library is add a one liner to their build.gradle dependencies.

Using personal library hosted on github as gradle dependency

I have an android library that is hosted on github and need to add it as a dependency to another project without manually cloning the repository and adding it as a module dependency. How do I go about creating my own gradle dependency with link from github? Thanks!
If you've pushed your code to GitHub then sharing your library is easy with JitPack.
Your users will just need to add the repository to their build.gradle:
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
and then your GitHub repository as dependency:
dependencies {
compile 'com.github.YourUsername:Repo:Release'
}
JitPack acts as a maven repository and can be used like Maven Central. The nice thing is that you don't have to upload your library. Behind the scenes JitPack will check out the code from GitHub and compile it. As you publish a new release on GitHub it becomes available for others to use.
There is also a guide on how to prepare an Android project.
You have to release your library to a repository which can be used by Gradle. When you want the library to be publicly available you can publish it to Maven Central. See http://central.sonatype.org/pages/gradle.html#releasing-the-deployment-to-the-central-repository for details about how to publish your library from gradle to Maven Central.
Once published in Maven Central use the normal gradle dependency declaration.
Github is not a maven repository.
if it's "free for all" license, you can clone project and post it for example in jCenter, then add it as gradle dependency.

Github Project not available on android studio

I forked a project and I made a little modification on https://github.com/oursgris/datetimepicker
How can I make it available in android studio ?
I tryied to add in build.gradle :
dependencies {
compile 'com.github.oursgris.datetimepicker:library:0.0.3'
}
I had an error : Failed to resolve: com.github.oursgris.datetimepicker:library:0.0.3
What did I missed ?
I manage to output aar file but I don't know how to make it available in android studio with a simple dependancy (like other projects)
Regards
You almost got it right. What was missing is that you need to add a repository that stores your 'aar' file. You can do this with JitPack:
repositories {
maven {
url "https://jitpack.io"
}
}
And then add your library as:
dependencies {
compile 'com.github.oursgris:datetimepicker:0.0.3'
}

Categories

Resources