Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building library with gradle which is in a sibling directory

I'm setting up an Android Studio project. This project has a uses some other libs which are included in the Git repository as submodules. So they have to be in the same root folder. (If this is wrong feel free to write an answer too this would fix me problem too.)

As far I understood gradle the dependencies the have to be in a subdirectory to use the compile project ':subdir:subsubdir' command.

I found something about the include command but I did not get it how to use this, this seems also to require files in any subdirectory. So I digged a little more and found the flatDir command in the scope of repositories but how can I use that?

If helpful or not here is my build.gradle:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:0.6.+'
    }
}
apply plugin: 'android'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.0"

    defaultConfig {
        minSdkVersion 7
        targetSdkVersion 19
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:+'
    compile project('../LibraryProjectName:Library')
    compile 'com.examlple.library:Library:1.0'
    repositories {
        flatDir {
            dirs '../LibraryProjectName/Library'
        }
    }
}
like image 727
rekire Avatar asked Jan 07 '14 09:01

rekire


1 Answers

I delt with the same tree hierarchy last week and made a simple sample to get the thing done.

Check out this sample on github.

The key is the use of the settings.gradle files. This sample can be built both from the root directory and from the DummyProject directory.

like image 96
Renaud Avatar answered Oct 16 '22 22:10

Renaud