Android Studio Best way import module from other repository

10.3k views Asked by At

I have to import a project from a Github repository as a module inside an Android Studio project that it committed into another repository.

The project I have to import from Github will be updated constantly so it means that I'll have to refresh every now and again for having the latest changes done on the module.

Since the new module as the base project will have independent development, which is the best way to import the module? should I check out the Github repository inside the Android Studio folder?

Thanks

3

There are 3 answers

2
Mohammad Ersan On BEST ANSWER

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

0
shkschneider On

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?)

1
Sergey Shustikov On
  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.