Robolectric 4 AndroidX NoClassDefFoundError MonitoringInstrumentation with IntelliJ 2018.3.4
Robolectric 4 AndroidX NoClassDefFoundError MonitoringInstrumentation with IntelliJ 2018.3.4
问题
- 切换到 androidX
后
- 使用多模块 Android 库
- 使用 IntelliJ 2018.3.4 #IC-183.5429.30
- 使用 Robolectric 4.1 和 android gradle 插件 3.3.1
在执行 Robolectric 测试时,我收到:
java.lang.NoClassDefFoundError: androidx/test/runner/MonitoringInstrumentation
没有重复问题:
我阅读了使用 google 或 Whosebug 搜索时弹出的其他主题,但它们是关于一个更具体的错误,可以通过添加特定的依赖项来解决。就我而言,我无法确定要添加哪个依赖项。
我读到 Android Studio 3.3 和 Robolectric 4.0 不需要解决方法。
- 使用 Android Studio 3.3.1+ 和 Robolectric 4.0+
这对我有用。
我将依赖添加到 androidx.test:core
对于正在测试的构建类型。
在我的例子中是 debug 所以在 build.gradle 我添加
debugImplementation 'androidx.test:core:1.2.0'
问题
- 切换到 androidX 后
- 使用多模块 Android 库
- 使用 IntelliJ 2018.3.4 #IC-183.5429.30
- 使用 Robolectric 4.1 和 android gradle 插件 3.3.1
在执行 Robolectric 测试时,我收到:
java.lang.NoClassDefFoundError: androidx/test/runner/MonitoringInstrumentation
没有重复问题:
我阅读了使用 google 或 Whosebug 搜索时弹出的其他主题,但它们是关于一个更具体的错误,可以通过添加特定的依赖项来解决。就我而言,我无法确定要添加哪个依赖项。
我读到 Android Studio 3.3 和 Robolectric 4.0 不需要解决方法。
- 使用 Android Studio 3.3.1+ 和 Robolectric 4.0+
这对我有用。
我将依赖添加到 androidx.test:core 对于正在测试的构建类型。
在我的例子中是 debug 所以在 build.gradle 我添加
debugImplementation 'androidx.test:core:1.2.0'