Android Studio Best way import module from other repository

房东的猫 提交于 2019-12-10 02:21:13

问题


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


回答1:


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




回答2:


  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.




回答3:


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



来源:https://stackoverflow.com/questions/30798638/android-studio-best-way-import-module-from-other-repository

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