1

I've created a project and a library separately using Android Studio, each in a separate folder inside some directory.

I tried to add the library as a module to the project, and noticed that instead of just referencing the library like in Eclipse, the library was copied inside the project directory.

That means that if this happened N times for N projects, then I'll have N copies of the library and I'll need to update them all when any update is to be done. I'm working on v 1.0.2 of Android Studio.

Any one has a better idea to do it?

Hamzeh Soboh
  • 7,572
  • 5
  • 43
  • 54

1 Answers1

1

Three options I know of:

  1. You can specify the path to the external library:

Android studio add external project to build.gradle

  1. Include the compiled jar file from the library in the libs directory of the N apps.

  2. Publish the artifact (the jar from library project) to a gradle repository and then you can add dependencies to that project just like you would for the support library etc.

See http://gradle.org/docs/current/userguide/artifact_management.html

Community
  • 1
  • 1
weston
  • 54,145
  • 21
  • 145
  • 203
  • I'm trying the first solution, but seems that 'projectDir' is deprecated in the new gradle. Do you no what is the alternative? – Hamzeh Soboh Jan 25 '15 at 19:26
  • Sorry no, I've not used it myself. – weston Jan 25 '15 at 19:28
  • Did you look at some of the other answers on that question I linked to, some of them appear newer than the accepted answer so might be the right way to do it now. – weston Jan 27 '15 at 08:40