如何修复java.lang.NoClassDefFoundError:无法解决以下问题:Ljava / beans / Introspector错误

时间:2019-06-30 09:11:21

标签: android mockito integration-testing powermock

因此,我正在尝试为现有应用编写测试,并且我需要使用MockitoPowerMock,但是我一直收到此错误:

  

java.lang.NoClassDefFoundError:无法解决以下问题:   Ljava / beans / Introspector;

我搜索了一段时间并检查了this,这没有帮助,我真的不想使用this

这是我的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"
}

正如我之前提到的,我遇到此错误:

  

java.lang.NoClassDefFoundError:无法解决以下问题:Ljava / beans / Introspector;

任何帮助您解决该问题的帮助或可能的教程/博客/链接,将不胜感激。

仅供参考:在build.gradle中取消注释此行(androidTestImplementation "org.mockito:mockito-android:2.28.2")时,会出现此错误:

  

org.gradle.api.tasks.TaskExecutionException:任务':app:transformClassesWithDexBuilderForDebugAndroidTest'的执行失败

0 个答案:

没有答案