In Android Studio I'm trying to compile an Android application module which uses an Android library.
The library includes a jar file for Bugsense (included automatically by gradle).
Although the library module compiles correctly, the application module fails because it is looking for the Bugsense jar file that is used within the library module.
I do have a workaround which allows the project to compile. By also including the Bugsense dependency in the project everything works.
My question is: How do I make the project compile without duplicating the Bugsense dependency?
Here is my build.gradle file for the library project.
buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.6.+' } } apply plugin: 'android-library' repositories { mavenCentral() maven { url 'http://www.bugsense.com/gradle/' } } android { compileSdkVersion 15 buildToolsVersion "19.0.0" defaultConfig { minSdkVersion 15 targetSdkVersion 15 } } dependencies { compile 'com.bugsense.trace:bugsense:3.6' } The library project is called "util"
Following is the android section of the build.gradle for the application
android { compileSdkVersion 15 buildToolsVersion '19.0.0' defaultConfig { minSdkVersion 15 targetSdkVersion 15 } dependencies { compile project(':util') } } When I compile this I get the following error:
* What went wrong: A problem occurred configuring project ':br'. > Failed to notify project evaluation listener. > Could not resolve all dependencies for configuration ':br:_DebugCompile'. > Could not find com.bugsense.trace:bugsense:3.6. Required by: dss:br:unspecified > dss:util:unspecified I can make the compile work by adding Bugsense to the repositories section of the build.gradle file for the application. Following is the code I added to the build.gradle file for the application project.
repositories { mavenCentral() maven { url 'http://www.bugsense.com/gradle/' } } Remember, the above code is in the build.gradle for the application project AND the library.
How do I avoid adding the Bugsense dependency to both the application and library projects?
UPDATES:
I'm using Gradle 1.8
I'm compiling from the command line with "gradle clean assembleDebug"
The following is the complete build.gradle file for the application project:
buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.6.+' } } apply plugin: 'android' repositories { mavenCentral() //maven { url 'http://www.bugsense.com/gradle/' } } android { compileSdkVersion 15 buildToolsVersion '19.0.0' defaultConfig { minSdkVersion 15 targetSdkVersion 15 testPackageName "com.myapp.test" } dependencies { compile project(':common') compile project(':util') } } dependencies { instrumentTestCompile 'com.jayway.android.robotium:robotium-solo:4.3' instrumentTestCompile 'com.squareup:fest-android:1.0.+' instrumentTestCompile 'com.squareup.spoon:spoon-client:1.0.+' instrumentTestCompile 'com.google.guava:guava:15.0' } configurations { spoon } dependencies { spoon 'com.squareup.spoon:spoon-runner:1.0.5' }