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

前端 未结 3 921
独厮守ぢ
独厮守ぢ 2020-12-13 03:19

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

3条回答
  •  盖世英雄少女心
    2020-12-13 03:46

    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

提交回复
热议问题