Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Import Module without creating copy in Android Studio

I am using Android Studio 1.3.1 and trying to add library module to an existing android application. The library module is available in a git repository. I am able to import the module, but it creates a copy inside the existing app. Hence I am not able to pull the updates in the module.

I am sure there is a way to import external libraries from an existing Android project in studio.

I found the below stackoverflow posts related to my doubt -

  1. How to import a Module on Android Studio 0.5.1?
  2. Android Studio 0.8.1 Creating Modules without copying files?

Both seem not to work for me. I also found couple of comments from other users saying it is also not working for them in the latest version of studio.

Here are the things that I tried

// in settings.gradle
include ':libraryName'
project(':libraryName').projectDir=new File('/path/to/library')

// in build.gradle
compile project(':libraryName')

Also I tried using this this url

Any help is appreciated. Thanks

like image 737
Nirmalkumar Avatar asked Sep 04 '15 10:09

Nirmalkumar


People also ask

Can we import module from source in Android Studio?

Select the source directory of the Module you want to import and click Finish. Open Project Structure Dialog (You can open the PSD by selecting File > Project Structure) and from the left panel click on Dependencies. Select the module from the Module(Middle) section In which you want to add module dependency.

How do I import a module into gradle?

In Android Studio, Right-clicking on the folder to add as library. Editing the dependencies in the build. gradle file, adding: compile fileTree(dir: 'libs', include: '*. jar')}


1 Answers

Set the projectDir and by setting the rootProject.name it will also show up in your IDEs Project pane:

// in settings.gradle
include ':app'
rootProject.name = "Project name"
include ':libraryName'
project (":libraryName").projectDir = new File("../path/to/library")
// in build.gradle
compile project(':libraryName')
like image 123
Kubus Avatar answered Sep 22 '22 23:09

Kubus