Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sharing own module across projects Android Studio

I'm struggling badly with moving from Eclipse to Android Studio.

Basically, I get that an Android Studio project is more like a workspace and a module more like a project...

However, in the Android Studio start page you can only create projects, so how do you share a module (i.e. a project in eclipse terms) across projects?

Basically, I have a number of apps that use a shared library I've created, in Eclipse all I do is flag it as a library and in each project simply link to it.

I have absolutely no idea how to do this in Android Studio. The examples for creating modules seem to take you as far as creating a module for no real purpose other than to use it within one app.

I first imported my library as a project in android studio, but that proved pointless, thinking that was how to do it because I want it kept separate in my version control system.

I then created a temporary module inside my app, but then it stores it within the project and in my other apps I cannot find a way to import the modules, so I really don't see what the point of a module is when it's embedded in a project and can't be separated or referenced anywhere else.

Thanks for any help.

like image 630
Neil Walker Avatar asked Aug 14 '14 16:08

Neil Walker


1 Answers

Consider your library project name common-lib

Open build.gradle of the projects to which you want to add library add add the following

dependencies {    
    compile project(':common-lib')    
}

and sync gradle

like image 69
sujithvm Avatar answered Nov 03 '22 12:11

sujithvm