Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 378
Владимир Широков Avatar asked Dec 17 '15 07:12

Владимир Широков


People also ask

Can I use GitHub library in Android Studio?

Android Studio makes it easy to push changes to your favorite Open Source, professional, or personal projects on GitHub. In this tutorial, we'll learn how to use GitHub with Android Studio.


2 Answers

To achieve it you have some ways:

  1. publish your library (artifact) in central maven or jcenter.
  2. use a github repo and the jitpack plugin
  3. 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

like image 187
Gabriele Mariotti Avatar answered Sep 23 '22 06:09

Gabriele Mariotti


Refer Jitpack is best to import your project or libs from Github to gradle

For more information refer Gabriele Mariotti answer

like image 26
M D Avatar answered Sep 22 '22 06:09

M D