title: AndroidTest Failed while running from command line :app:connectedDebugAndroidTest
body: <p>I'm using android spring <code>RestTemplate</code> for making REST service calls on my app. I added android Instrumentation test which includes mocking the REST service calls.
  All my test are running fine while running from android studio, but the test failed to load spring mock class while running from terminal using </p>
  
  <pre><code>   ./gradlew clean :app:connectedDebugAndroidTest
  </code></pre>
  
  <p>The spring test dependency on build.gradle </p>
  
  <pre><code>    androidTestCompile("org.springframework:spring-test:3.2.8.RELEASE")
  </code></pre>
  
  <p>If i change to <code>compile</code> instead of <code>androidTestCompile</code> , the android test are running fine from terminal . 
  Since i don't want this dependency on my production APK any help , appreciated. </p>
  
  <p>This the log while starting the test</p>
  
  <blockquote>
    <p>08-05 00:04:12.585 22274-22302/com.libin.androiduitesting
    E/TestLoader: Could not find class:
    org.springframework.asm.commons.JSRInlinerAdapter 08-05 00:04:12.587
    22274-22302/com.libin.androiduitesting E/TestLoader: Could not find
    class: org.springframework.asm.commons.TryCatchBlockSorter 08-05
    00:04:12.593 22274-22302/com.libin.androiduitesting E/TestLoader:
    Could not find class:
    org.springframework.cglib.transform.AbstractProcessTask 08-05
    00:04:12.593 22274-22302/com.libin.androiduitesting E/TestLoader:
    Could not find class:
    org.springframework.cglib.transform.AbstractTransformTask 08-05
    00:04:12.603 22274-22302/com.libin.androiduitesting E/TestLoader:
    Could not find class:
    org.springframework.core.convert.support.ConvertingPropertyEditorAdapter
    08-05 00:04:12.610 22274-22302/com.libin.androiduitesting
    E/TestLoader: Could not find class:
    org.springframework.core.io.ResourceEditor 08-05 00:04:12.611
    22274-22302/com.libin.androiduitesting E/TestLoader: Could not find
    class: org.springframework.core.io.support.ResourceArrayPropertyEditor
    08-05 00:04:12.617 22274-22302/com.libin.androiduitesting
    E/TestLoader: Could not find class:
    org.springframework.mock.http.MockHttpInputMessage 08-05 00:04:12.618
    22274-22302/com.libin.androiduitesting E/TestLoader: Could not find
    class: org.springframework.mock.http.MockHttpOutputMessage 08-05
    00:04:12.618 22274-22302/com.libin.androiduitesting E/TestLoader:
    Could not find class:
    org.springframework.mock.http.client.MockClientHttpRequest 08-05
    00:04:12.618 22274-22302/com.libin.androiduitesting E/TestLoader:
    Could not find class:
    org.springframework.mock.http.client.MockClientHttpResponse 08-05
    00:04:12.618 22274-22302/com.libin.androiduitesting E/TestLoader:
    Could not find class:
    org.springframework.mock.jndi.ExpectedLookupTemplate 08-05
    00:04:12.619 22274-22302/com.libin.androiduitesting E/TestLoader:
    Could not find class:
    org.springframework.mock.jndi.SimpleNamingContext 08-05 00:04:12.619
    22274-22302/com.libin.androiduitesting E/TestLoader: Could not find
    class: org.springframework.mock.jndi.SimpleNamingContextBuilder 08-05
    00:04:12.619 22274-22302/com.libin.androiduitesting E/TestLoader:
    Could not find class:
    org.springframework.mock.web.DelegatingServletInputStream 08-05
    00:04:12.619 22274-22302/com.libin.androiduitesting E/TestLoader:
    Could not find class:
    org.springframework.mock.web.DelegatingServletOutputStream 08-05
    00:04:12.620 22274-22302/com.libin.androiduitesting E/TestLoader:
    Could not find class: org.springframework.mock.web.MockBodyContent
    08-05 00:04:12.620 22274-22302/com.libin.androiduitesting
    E/TestLoader: Could not find class:
    org.springframework.mock.web.MockExpressionEvaluator 08-05
    00:04:12.620 22274-22302/com.libin.androiduitesting E/TestLoader:
    Could not find class: org.springframework.mock.web.MockFilterChain
    08-05 00:04:12.620 22274-22302/com.libin.androiduitesting
    E/TestLoader: Could not find class:
    org.springframework.mock.web.MockFilterConfig 08-05 00:04:12.620
    22274-22302/com.libin.androiduitesting E/TestLoader: Could not find
    class: org.springframework.mock.web.MockHttpServletRequest 08-05
    00:04:12.621 22274-22302/com.libin.androiduitesting E/TestLoader:
    Could not find class:
    org.springframework.mock.web.MockHttpServletResponse 08-05
    00:04:12.621 22274-22302/com.libin.androiduitesting E/TestLoader:
    Could not find class: org.springframework.mock.web.MockHttpSession
    08-05 00:04:12.621 22274-22302/com.libin.androiduitesting
    E/TestLoader: Could not find class:
    org.springframework.mock.web.MockJspWriter 08-05 00:04:12.621
    22274-22302/com.libin.androiduitesting E/TestLoader: Could not find
    class: org.springframework.mock.web.MockMultipartFile 08-05
    00:04:12.621 22274-22302/com.libin.androiduitesting E/TestLoader:
    Could not find class:
    org.springframework.mock.web.MockMultipartHttpServletRequest 08-05
    00:04:12.622 22274-22302/com.libin.androiduitesting E/TestLoader:
    Could not find class: org.springframework.mock.web.MockPageContext
    08-05 00:04:12.622 22274-22302/com.libin.androiduitesting
    E/TestLoader: Could not find class:
    org.springframework.mock.web.MockRequestDispatcher 08-05 00:04:12.623
    22274-22302/com.libin.androiduitesting E/TestLoader: Could not find
    class: org.springframework.mock.web.MockServletConfig 08-05
    00:04:12.623 22274-22302/com.libin.androiduitesting E/TestLoader:
    Could not find class: org.springframework.mock.web.MockServletContext
    08-05 00:04:12.628 22274-22302/com.libin.androiduitesting
    E/TestLoader: Could not find class:
    org.springframework.mock.web.PassThroughFilterChain 08-05 00:04:12.628
    22274-22302/com.libin.androiduitesting E/TestLoader: Could not find
    class: org.springframework.mock.web.portlet.MockActionRequest 08-05
    00:04:12.629 22274-22302/com.libin.androiduitesting E/TestLoader:
    Could not find class:
    org.springframework.mock.web.portlet.MockActionResponse 08-05
    00:04:12.629 22274-22302/com.libin.androiduitesting E/TestLoader:
    Could not find class: org.springframework.mock.web.portlet.MockBaseURL
    08-05 00:04:12.629 22274-22302/com.libin.androiduitesting
    E/TestLoader: Could not find class:
    org.springframework.mock.web.portlet.MockCacheControl 08-05
    00:04:12.630 22274-22302/com.libin.androiduitesting E/AndroidRuntime:
    FATAL EXCEPTION: Instr: android.support.test.runner.AndroidJUnitRunner
                                                                                Process: com.libin.androiduitesting, PID: 22274
                                                                                java.lang.NoClassDefFoundError:
    org.springframework.mock.web.portlet.MockClientDataRequest
                                                                                    at java.lang.Class.classForName(Native Method)
                                                                                    at java.lang.Class.forName(Class.java:324)
                                                                                    at
    android.support.test.internal.runner.TestLoader.doLoadClass(TestLoader.java:92)
                                                                                    at
    android.support.test.internal.runner.TestLoader.loadIfTest(TestLoader.java:113)
                                                                                    at
    android.support.test.internal.runner.TestRequestBuilder.loadClassesFromClassPath(TestRequestBuilder.java:801)
                                                                                    at
    android.support.test.internal.runner.TestRequestBuilder.build(TestRequestBuilder.java:747)
                                                                                    at
    android.support.test.runner.AndroidJUnitRunner.buildRequest(AndroidJUnitRunner.java:354)
                                                                                    at
    android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:260)
                                                                                    at
    android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1879)</p>
  </blockquote>