title: How to configure the order of libraries in the classpath for Android Studio?
body: <p>I would like to change the order of libraries in the classpath for Android Studio. I am trying to <strong>run unit tests</strong> with JUnit 4 from <strong>within the IDE</strong>. This works following the <a href="http://www.slideshare.net/tobiaspreuss/how-to-setup-unit-testing-in-android-studio" rel="nofollow noreferrer">instruction in these slides</a>.</p>
  
  <p>I wonder if it is possible to <strong>configure the order of the libraries</strong> - other then suggested in the slides - via the <em>Run Configuration</em> of Android Studio?</p>
  
  <p>The first attempt was to change the order of dependencies in the <em>Project Structure</em> dialog in the <em>Dependency</em> tab of the project module as show in the screenshot.</p>
  
  <p><img src="https://i.stack.imgur.com/kRetx.png" alt="Project Structure"></p>
  
  <p>The second guess was to include the classpath configuration in the <code>build.gradle</code> file. There are a couple of <strong>vague</strong> ideas about this:</p>
  
  
  
  <pre><code>sourceSets.main.compileClasspath = file("foo.jar") + sourceSets.main.compileClasspath
  </code></pre>
  
  <p>...</p>
  
  
  
  <pre><code>sourceSets.test.compileClasspath = configurations.robo + sourceSets.test.compileClasspath
  sourceSets.test.runtimeClasspath = configurations.robo + sourceSets.test.runtimeClasspath
  </code></pre>
  
  <ul>
  <li>Sources: [<a href="http://forums.gradle.org/gradle/topics/how_do_i_control_the_order_of_compiletime_classpaths#reply_7726876" rel="nofollow noreferrer"><a href="http://www.slideshare.net/tobiaspreuss/how-to-setup-unit-testing-in-android-studio" rel="nofollow noreferrer">1</a></a>], [<a href="https://stackoverflow.com/a/7281162/356895">2</a>]</li>
  </ul>