title: Receiving java.lang.NoClassDefFoundError: when adding library to UIAutomator project using Android Studio built with Gradle
body: <p>Im trying to add Joda-Time as a dependency to my UIAutomator test project in Android Studio using Gradle and I get the following error when I try to use the LocalDate class in Joda:</p>
  
  <pre><code>java.lang.NoClassDefFoundError: org.joda.time.LocalDate
  </code></pre>
  
  <p>Im not sure what Im doing wrong.  Im pretty sure my build.gradle and Test Class is correct.  This probably isnt a Joda problem...Im just implementing the library wrong.</p>
  
  <p>Here is my gradle.properties:</p>
  
  <pre><code>androidSdkHome=/Users/timbo/sdk
  androidSdkTarget=android-20
  androidSdkBuildToolsDir=build-tools/android-4.4W/
  </code></pre>
  
  <p>Heres my build.gradle file:</p>
  
  <pre><code>apply plugin: 'java'
  apply plugin: 'idea'
  
  sourceCompatibility = 1.7
  targetCompatibility = 1.7
  
  version = '0.1'
  
  project.ext {
      dexDir = new File('build/dex')
      distDir = new File('./dist')
  }
  
  repositories {
      mavenCentral()
  }
  
  dependencies {
      compile fileTree(dir: androidSdkHome + '/platforms/' + androidSdkTarget, include: '*.jar')
      compile group: 'junit', name: 'junit', version: '4.11'
      compile group: 'joda-time', name: 'joda-time', version: '2.5'
  }
  
  jar {
      doLast {
          tasks.dex.execute()
      }
  }
  
  task dex(dependsOn: jar, type:Exec) {
      println 'Building dex...'
      project.dexDir.mkdirs()
      workingDir '.'
      commandLine androidSdkHome + '/' + androidSdkBuildToolsDir + '/' + 'dx', '--dex', '--no-strict', '--output=' + buildDir +'/dex/' + project.name + '.jar', jar.archivePath
      doLast {
          tasks.dist.execute()
      }
  }
  
  task dist(dependsOn:dex, type:Copy) {
      project.distDir.mkdirs()
      from(project.dexDir)
      into(project.distDir)
      include('*.jar')
  }
  </code></pre>
  
  <p>Here is my Test:</p>
  
  <pre><code>package com.mofo.hilton.android.uiautomator.tests;
  
  import com.android.uiautomator.core.UiObjectNotFoundException;
  import com.android.uiautomator.testrunner.UiAutomatorTestCase;
  
  import org.joda.time.LocalDate;
  
  /**
   * Created by TimBo on 10/11/14.
   */
  public class TestJodaTime extends UiAutomatorTestCase {
  
      @Override
      public void setUp() throws UiObjectNotFoundException {
  
  
      }
  
      public void testJodaTime() throws UiObjectNotFoundException {
  
          LocalDate dt = new LocalDate();
          LocalDate lastDayOfMonth = dt.dayOfMonth().withMaximumValue();
          System.out.println(lastDayOfMonth);
  
      }
  }
  </code></pre>
  
  <p>And here is an image of the External libraries that are in my project:</p>
  
  <p><img src="https://content.screencast.com/users/tboland/folders/Jing/media/bd52c1ec-fdbb-4803-bab9-6316b1a4d4da/00000010.png" alt="external libraries in AS"></p>