Skip to content

Espresso 3.5.1 crashes with IncompatibleClassChangeError on API 28 - 30 when minSdk 28 #1642

Closed
@ursar

Description

@ursar

Description

After upgrading to Espresso 3.5.1 view assertion (onView(...).check(matches(...))) for view into scrollView crashes on API 28-30 when used minSdk 28.

Steps to Reproduce

  1. Create new project, with a basic Espresso test
  2. Upgrade Espresso to 3.5.1
  3. Setup minSkd 28
  4. Add in test assert .check(matches(isDisplayed())) for view in scrollView when it is not visible on the screen
  5. Run test on device or emulator with API 28-30

Expected Results

Test fails with
androidx.test.espresso.base.AssertionErrorHandler$AssertionFailedWithCauseError: '(view has effective visibility <VISIBLE> and view.getGlobalVisibleRect() to return non-empty rectangle)' doesn't match the selected view. Expected: (view has effective visibility <VISIBLE> and view.getGlobalVisibleRect() to return non-empty rectangle) Got: view.getGlobalVisibleRect() returned empty rectangle

Actual Results

Test fails with
java.lang.IncompatibleClassChangeError: Class 'org.hamcrest.StringDescription' does not implement interface 'java.lang.Iterable' in call to 'java.util.Iterator java.lang.Iterable.iterator()' (declaration of 'org.hamcrest.BaseDescription' appears in /data/app/gmk57.testespresso.test-8etyGcYaxocoQ-VLXtELkg==/base.apk) at org.hamcrest.BaseDescription.appendValueList(BaseDescription.java:76) at androidx.test.espresso.matcher.ViewMatchers.getMismatchDescriptionString(ViewMatchers.java:3) at androidx.test.espresso.matcher.ViewMatchers.assertThat(ViewMatchers.java:5) at androidx.test.espresso.assertion.ViewAssertions$MatchesViewAssertion.check(ViewAssertions.java:7) at androidx.test.espresso.ViewInteraction$SingleExecutionViewAssertion.check(ViewInteraction.java:2) at androidx.test.espresso.ViewInteraction$2.call(ViewInteraction.java:14) at androidx.test.espresso.ViewInteraction$2.call(ViewInteraction.java:1) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6669) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

AndroidX Test and Android OS Versions

Reproduced on: Android API 28-30
Not reproduced on: Android API 31-33
androidx.test.ext:junit:1.1.5
androidx.test.espresso:espresso-core:3.5.1
Gradle 7.4.2
AGP 7.3.1
buildToolsVersion "33.0.1"
compileSdk 33
minSdk 28
targetSdkVersion 33
Android Studio Dolphin | 2021.3.1 Patch 1

Link to a public git repo demonstrating the problem:

Link

Additional info

When used minSdk 27 problem not reproduced.
On espresso 3.5.0 problem reproduced.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions