Android Studio Best way import module from other repository

梦想的初衷 提交于 2019-12-05 02:02:24

I'd advice to use Jitpack

Jitpack: Easy to use package repository for GitHub, just include it inside your gradle, and now you can deal with github project as a module

Thanks Jitpack <3


For example: we have this repository: https://github.com/florent37/MaterialViewPager

and with Jitpack in your gradle:

repositories {
    maven {
        url "https://jitpack.io"
    }
}

dependencies {
        compile 'com.github.florent37:MaterialViewPager:1.0.5'
}

And you can use it with private repositories, but it require signup/login

  1. Clone you git repository into local folder.
  2. In Android Studio choose File -> Import Module and choose cloned directory project.
  3. If Android Studio do not detect VCS root go to the Settings->Version Control and setup your directory.

When you need update project just use a stadard IDE pull options(VCS->Update Project(Ctrl+T)).

I use stash options before pulling.

You should checkout the github repository in your Project folder for Android Studio to read.

And you'll have to keep it up-to-date.

You can run Git commands from a Gradle rule like so:

['sh', '-c', 'cd mymodule && git pull origin master && cd -'].execute()

(Just an example - credits to How to execute git command from build.gradle?)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!