79101

Gradle Android unit tests that depend on an 'aar' for build tool 0.11.+

I am using gradle build system to run Roboletric tests however I've encountered the problem that was described here Gradle Android unit tests that depend on an 'aar' but the solution only works for build tool version 0.9.+ and not 0.11.+ as I cannot find the exploded-aar directory. Any ideas?

Here's the partial build file

configurations { testLocalCompile { extendsFrom compile } } sourceSets { testLocal { java.srcDir file('src/test/java') resources.srcDir file('src/test/res') compileClasspath += configurations.testLocalCompile runtimeClasspath += compileClasspath } } dependencies { testLocalCompile fileTree(dir: "$project.buildDir/intermediates/exploded-aar", include: "**/classes.jar") } task localTest(type: Test, dependsOn: assemble) { testClassesDir = sourceSets.testLocal.output.classesDir android.sourceSets.main.java.srcDirs.each { dir -> def buildDir = dir.getAbsolutePath().split('/') buildDir = (buildDir[0..(buildDir.length - 4)] + ['build', 'intermediates', 'classes', 'debug']).join('/') sourceSets.testLocal.compileClasspath += files(buildDir) sourceSets.testLocal.runtimeClasspath += files(buildDir) } classpath = sourceSets.testLocal.runtimeClasspath } check.dependsOn localTest

Answer1:

That change again in <strong>0.12.2</strong>

http://tools.android.com/tech-docs/new-build-system

Move unzipped aar back in each project as a temporary fix for a possible race condition.

So you have to change the dependency back:

unitTestCompile fileTree(dir: "$project.buildDir/intermediates/exploded-aar/", include:"**/classes.jar")

(PS: do not know if is it the right way to post this in stackoverflow)

Answer2:

Fixed it: it seems like in the 0.11.+ build tool the exploded-aar folder is moved to root. I had to change the dependency:

testLocalCompile fileTree(dir: "${rootDir}/build/exploded-aar", include: "**/classes.jar")

Recommend

  • Free XML based java gui language with builder
  • javah NullPointerException while using ANT in Eclipse Indigo
  • How to install charlock_holmes dependency libicu-dev on Heroku
  • Accessing configurations ResolutionStrategy from a plugin
  • How to upload artifact to network drive using gradle?
  • Installing “libv8” gem for “therubyracer” on Windows
  • How to get a table cell value using jQuery
  • scrollOverflow not working in fullPage.js
  • Calling javaScript Function
  • Can't resolve 'jquery' with typescript
  • JQuery form validation and submit scripts conflict
  • How to stamp out template in self contained custom elements with vanilla js?
  • File loader changed image file name but not the file name in HTML file
  • Is it better to use the “hidden” CSS attribute or fetch each set of new images?
  • MAVEN : Run Multiple Maven Project using Maven Test
  • Get a trait object reference from a vector
  • google maps autocomplete bounces back already cleared text …odd…odd…odd
  • Is there a way to dynamically embed PDF Files in a JSP pulled from the file system?
  • Outputting SharePoint Hyperlink Column as URL
  • Doctrine/Symfony entity generator and generating entity from one table
  • Uncaught TypeError: $(…).select2 is not a function
  • How to view images from protected folder with php?
  • Display images in Django
  • Python urlparse: small issue
  • OpenGL ES texture problem, 4 duplicate columns and horizontal lines (Android)
  • Display issues when we change from one jquery mobile page to another in firefox
  • Deselecting radio buttons while keeping the View Model in synch
  • Resize panoramic image to fixed size
  • Cross-Platform Protobuf Serialization
  • JSON with duplicate key names losing information when parsed
  • Importing jscolor library in angular 2
  • Jquery - Jquery Wysiwyg return html as a string
  • Google cloud sdk not working when python points python3
  • Why winpcap requires both .lib and .dll to run?
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • How to format a variable of double type
  • Load html files in TinyMce
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • coudnt use logback because of log4j
  • JaxB to read class hierarchy