android gradle: how to import a library module

Sometimes you finish an module and you want to reuse the code for other application, following steps may help!

1, Copy the module sources folder into the root of project you developing;

2, Follow this guide to config build.gradle file of your module: http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Library-projects, ;

3, (Using idea intellij) File-> new-> module from existing sources, select the module folder you just copied-> click finish. If any errors reported, config build.gradle of the imported module to get rid of them.

4, Add module name to "settings.gradle" file which locates in project root. For example I want to import a moudle called "swipelistview":

include ':app', ':swipelistview'.

5, Add depency to "build.gradle" file of the main module, like this:

dependencies {
    compile project(':swipelistview')
}

6, rebuild your project!













你可能感兴趣的:(android gradle: how to import a library module)