Skip to content Skip to sidebar Skip to footer

Set Project Dependencies With Gradle

I am using Gradle for Android with Eclipse (NOT Android Studio and please do not suggest to change the IDE). My project.properties file got this line: android.library.reference.1=.

Solution 1:

If you want to compile sources of your library :

1) Put your project library in your root project

Tree is like the following :

RootProject
  +- build.gradle
  +- settings.gradle
  +- Lib1/
      +- build.gradle
      +- ...
  +- Project/
      +- build.gradle
      +- ...

2) Edit your settings.gradle

include':Lib1'include':Project'

3) Add dependency in your Project's build.gradle file

dependencies {
    [...]
    compile project(':Lib1')
}

If you want to add jars :

1) Create a libs folder in your Project's dir

2) Add this dir as reprositories in your gradle file

repositories { 
    flatDir {
        dirs'libs' 
    } 
}

3) Put your jar in this dir and add dependencies in your Project's build.gradle

dependencies {
    compile(name:'mylib',ext:'jar')
}

Post a Comment for "Set Project Dependencies With Gradle"