title: How to fix java.lang.NoClassDefFoundError: Failed resolution of: Ljava/beans/Introspector error
body: <p>So I'm trying to write tests for an existing app, and I need to use <code>Mockito</code> and <code>PowerMock</code>, but I keep getting this error:</p>
  
  <blockquote>
    <p>java.lang.NoClassDefFoundError: Failed resolution of:
    Ljava/beans/Introspector;</p>
  </blockquote>
  
  <p>I googled for a while and checked <a href="https://stackoverflow.com/questions/45626317/how-to-use-powermock-on-android-sdk">this</a> which wasn't helpful and I really don't want to use <a href="https://stackoverflow.com/questions/15065545/using-jars-that-use-java-beans-classes-introspector-beaninfo-or-propertydescri">this</a></p>
  
  <p>Here's part of my build.gradle</p>
  
  <pre><code>android {
      defaultConfig {
          useLibrary 'org.apache.http.legacy'
          testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
      }
  }
  
  dependencies {
      androidTestImplementation 'androidx.test:runner:1.2.0'
      androidTestImplementation 'androidx.test:rules:1.2.0'
      androidTestImplementation 'org.hamcrest:hamcrest-library:1.3'
  
  // I had to comment this line, since it caused a different error
  //    androidTestImplementation "org.mockito:mockito-android:2.28.2"
      androidTestImplementation 'junit:junit:4.12'
      androidTestImplementation 'org.powermock:powermock-core:2.0.2'
      androidTestImplementation 'org.powermock:powermock-module-junit4:2.0.2'
      androidTestImplementation 'org.powermock:powermock-api-mockito:1.7.4'
      androidTestImplementation "org.powermock:powermock-module-junit4-rule:2.0.0"
  
      androidTestImplementation "androidx.test.espresso:espresso-core:3.2.0"
  }
  </code></pre>
  
  <p>As I mentioned before I get this error:</p>
  
  <blockquote>
    <p>java.lang.NoClassDefFoundError: Failed resolution of: Ljava/beans/Introspector;</p>
  </blockquote>
  
  <p>Any help to resolve the issue or possible tutorials/blogs/links would be appreciated.</p>
  
  <p>FYI: I get this error when I uncomment this line (<code>androidTestImplementation "org.mockito:mockito-android:2.28.2"</code>) in build.gradle:</p>
  
  <blockquote>
    <p>org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformClassesWithDexBuilderForDebugAndroidTest'</p>
  </blockquote>