Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is the correct way to specify an Android library project to include its dependencies
    primarykey
    data
    text
    <p>In Android Studio I'm trying to compile an Android application module which uses an Android library.<br> The library includes a jar file for Bugsense (included automatically by gradle).</p> <p>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.</p> <p>I do have a workaround which allows the project to compile. By also including the Bugsense dependency in the project everything works.</p> <p>My question is: How do I make the project compile without duplicating the Bugsense dependency?</p> <p>Here is my build.gradle file for the library project. </p> <pre><code>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' } </code></pre> <p>The library project is called "util"</p> <p>Following is the android section of the build.gradle for the application</p> <pre><code>android { compileSdkVersion 15 buildToolsVersion '19.0.0' defaultConfig { minSdkVersion 15 targetSdkVersion 15 } dependencies { compile project(':util') } } </code></pre> <p>When I compile this I get the following error:</p> <pre><code>* What went wrong: A problem occurred configuring project ':br'. &gt; Failed to notify project evaluation listener. &gt; Could not resolve all dependencies for configuration ':br:_DebugCompile'. &gt; Could not find com.bugsense.trace:bugsense:3.6. Required by: dss:br:unspecified &gt; dss:util:unspecified </code></pre> <p>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.</p> <pre><code>repositories { mavenCentral() maven { url 'http://www.bugsense.com/gradle/' } } </code></pre> <p>Remember, the above code is in the build.gradle for the application project AND the library.</p> <p>How do I avoid adding the Bugsense dependency to both the application and library projects? </p> <p>UPDATES:</p> <p>I'm using Gradle 1.8</p> <p>I'm compiling from the command line with "gradle clean assembleDebug"</p> <p>The following is the complete build.gradle file for the application project:</p> <pre><code>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' } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload