So I'm trying to write tests for an existing app, and I need to use Mockito
and PowerMock
, but I keep getting this error:
java.lang.NoClassDefFoundError: Failed resolution of: Ljava/beans/Introspector;
I googled for a while and checked this which wasn't helpful and I really don't want to use this
Here's part of my build.gradle
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"
}
As I mentioned before I get this error:
java.lang.NoClassDefFoundError: Failed resolution of: Ljava/beans/Introspector;
Any help to resolve the issue or possible tutorials/blogs/links would be appreciated.
FYI: I get this error when I uncomment this line (androidTestImplementation "org.mockito:mockito-android:2.28.2"
) in build.gradle:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformClassesWithDexBuilderForDebugAndroidTest'