Testing library project with file dependencies

29 views
Skip to first unread message

Andras Nemeth

unread,
Nov 14, 2013, 6:20:29 AM11/14/13
to gradle-androi...@googlegroups.com
Hi,

I have a problem which is getting on my nerves, let me sum it up:

Let's say I have a gradle based android project, the project consists of an "App" module and a library module on which the "App" module depends. The library  module has one file dependency, for simplicity let's say it's dependency.jar:

MyProject
|
+-App
|
+-LIbrary
   |
   +-libs
   |  |
   |  +-dependency.jar
   |
   +-main
   |
   +-instrumentTest

(build.gradle (s) and settings.gradle are as follows)

settings.gradle: include ':App', ':Library'

build.gradle of Library:

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

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 16
    buildToolsVersion "19.0.0"

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 16
    }
}

dependencies {
    compile files('libs/dependency.jar')
}

build.gradle of App:

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 14
        targetSdkVersion 19
    }
}

dependencies {
    compile project(':Library')
}

As you can see from the project structure above (At leas I hope), the library project has some test. When I run the test from Android Studio I get errors of the following "flavour":

Gradle: java.lang.IllegalArgumentException: already added: L<some class in dependency.jar>;

The same class is being added from different sources, the problem is that I don't know why. Could somebody please enlighten me what is the cause of the problem. The thing is that this does not cause a problem when a dependency is comming from maven. Unfortunately the jar is not in any maven repo. Although I could put it in a local one, but I'd like to understand the real cause of the error, and how it can be solved.

Thanks for any help ;)

 
Reply all
Reply to author
Forward
0 new messages