title: Android, WireMock: java.lang.NoClassDefFoundError:
body: <p>Android Studio 2.3.1, Android 7.0</p>
  
  <p>My buld.gradle</p>
  
  <p>android {
       compileSdkVersion 23
       buildToolsVersion "23.0.3"</p>
  
  <pre><code> defaultConfig {
         minSdkVersion 15
         targetSdkVersion 23
              testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
              multiDexEnabled = true
      }
  dependencies {
      testCompile 'junit:junit:4.12'
      testCompile 'org.powermock:powermock-api-mockito:1.6.6'
      testCompile 'org.powermock:powermock-module-junit4:1.6.6'
      testCompile "org.mockito:mockito-core:+"
      androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
      androidTestCompile "org.mockito:mockito-android:2.7.21"
      androidTestCompile "org.powermock:powermock-api-mockito:1.6.6"
      androidTestCompile 'org.powermock:powermock-module-junit4:1.6.6'
      //WireMock
      androidTestCompile("com.github.tomakehurst:wiremock:2.6.0") {
          exclude group: 'org.apache.httpcomponents', module: 'httpclient'
          exclude group: 'org.ow2.asm', module: 'asm'
          exclude group: 'org.json', module: 'json'
      }
      androidTestCompile('com.squareup.okhttp3:mockwebserver:3.5.0') {
          exclude module: 'okhttp'
      }
  }
  </code></pre>
  
  <p>My instrumented test (in folder "androidTest")  with WireMock:</p>
  
  <pre><code>public class WireMockApplicationTestCase2 {
  
          @Rule
          public ActivityTestRule&lt;MainActivity&gt; activityRule = new ActivityTestRule&lt;&gt;(MainActivity.class);
  
          private Context androidTestContext;
          private Context applicationContext;
  
  
          @Before
          public void setUp() throws Exception {
              this.androidTestContext = InstrumentationRegistry.getContext();
              this.applicationContext = InstrumentationRegistry.getTargetContext().getApplicationContext();
              wireMockServer = new WireMockServer(8089);
              wireMockServer.start();
          }
  
          @Test
          public void testWiremockPlusOkHttp() throws IOException { 
              String serviceEndpoint = "http://127.0.0.1:" + 8089;   
              OkHttpClient okHttpClient = // some code fot http client;
              String uri = "/hello-world";
              Request request = new Request.Builder()
                      .url(serviceEndpoint + uri)
                      .build();
  
              Response response = okHttpClient.newCall(request).execute();  
              String responseBodyStr = response.body().string();
              assertEquals("hello world", responseBodyStr);
          }
   }
  </code></pre>
  
  <p>But when I start this test (on Android 7.0) I get error:</p>
  
  <pre><code>$ adb shell am instrument -w -r   -e debug false -e class com.mycompany.android.transport.WireMockApplicationTestCase2#testWiremockPlusOkHttp com.mycompany.android.dev.test/android.support.test.runner.AndroidJUnitRunner
  
  java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/impl/client/HttpClientBuilder;
  at com.github.tomakehurst.wiremock.http.HttpClientFactory.createClient(HttpClientFactory.java:48)
  at com.github.tomakehurst.wiremock.http.ProxyResponseRenderer.&lt;init&gt;(ProxyResponseRenderer.java:53)
  at com.github.tomakehurst.wiremock.core.WireMockApp.buildStubRequestHandler(WireMockApp.java:124)
  at com.github.tomakehurst.wiremock.WireMockServer.&lt;init&gt;(WireMockServer.java:71)
  at com.github.tomakehurst.wiremock.WireMockServer.&lt;init&gt;(WireMockServer.java:108)
  at com.mycompany.android.transport.WireMockApplicationTestCase2.setUp(WireMockApplicationTestCase2.java:46)
  at java.lang.reflect.Method.invoke(Native Method)
  at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
  at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
  at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
  at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
  at android.support.test.internal.statement.UiThreadStatement.evaluate(UiThreadStatement.java:55)
  at android.support.test.rule.ActivityTestRule$ActivityStatement.evaluate(ActivityTestRule.java:270)
  at org.junit.rules.RunRules.evaluate(RunRules.java:20)
  at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
  at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
  at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
  at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
  at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
  at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
  at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
  at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
  at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
  at org.junit.runners.Suite.runChild(Suite.java:128)
  at org.junit.runners.Suite.runChild(Suite.java:27)
  at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
  at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
  at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
  at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
  at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
  at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
  at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
  at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
  at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:59)
  at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:262)
  at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1932)
  Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.http.impl.client.HttpClientBuilder" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/com.mycompany.android.dev.test-2/base.apk", zip file "/data/app/com.mycompany.android.dev-1/base.apk"],nativeLibraryDirectories=[/data/app/com.mycompany.android.dev.test-2/lib/x86, /data/app/com.mycompany.android.dev-1/lib/x86, /system/lib, /vendor/lib]]
  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
  </code></pre>