Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ursar opened this issue Jan 6, 2023 · 15 comments
Assignees

Comments

@ursar
Copy link

ursar commented Jan 6, 2023

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.

@jonasborggren
Copy link

I have the same issue. Attempting to use the latest version of Jetpack Compose required me to upgrade Kotlin versions which then in turn required me to upgrade this library. I'll add more information here if I found something.

@brettchabot
Copy link
Collaborator

Sorry for the trouble. I'm working on a revamp of the release toolchain which will fix this issue.

As a workaround, you can try to upgrade your AGP version to the latest stable or use a min sdk < 28

@ZacSweers
Copy link

@brettchabot as in this is fixed by AGP 7.4.2?

@ZacSweers
Copy link

I just tested with 7.4.2 and it remains broken

@brettchabot
Copy link
Collaborator

Some IncompatibleClassChangeError's are fixed by using the latest AGP/D8 version, but not all.

@ishita-pandey
Copy link

We too are getting the same error for espresso 3.5.0. When can we expect a fix to this?
Would you recommend downgrading to 3.4.0 for the time being as we saw no regression in that version?

@montwell
Copy link

montwell commented Mar 1, 2023

I should note, that this appears to be flaky. When run in isolation, the test seems to pass fine. Also, only seeing this on API 29 at the moment.

@montwell
Copy link

montwell commented Mar 1, 2023

Reposting sanitized stacktrace

java.lang.IncompatibleClassChangeError: Class 'androidx.test.espresso.action.Tap$1' does not implement interface 'org.hamcrest.SelfDescribing' in call to 'void org.hamcrest.SelfDescribing.describeTo(org.hamcrest.Description)' (declaration of 'org.hamcrest.BaseDescription' appears in /data/app/com.XXX
at org.hamcrest.BaseDescription.appendDescriptionOf(BaseDescription.java:24)
at org.hamcrest.StringDescription.toString(StringDescription.java:28)
at org.hamcrest.BaseMatcher.toString(BaseMatcher.java:26)
at androidx.test.espresso.action.GeneralClickAction.getDescription(GeneralClickAction.java:1)
at androidx.test.espresso.action.ViewActions$1.getDescription(ViewActions.java:7)
at androidx.test.espresso.internal.data.model.ActionData.<init>(ActionData.kt:3)
at androidx.test.espresso.ViewInteraction.doPerform(ViewInteraction.java:22)
at androidx.test.espresso.ViewInteraction.-$$Nest$mdoPerform(Unknown Source:0)
at androidx.test.espresso.ViewInteraction$1.call(ViewInteraction.java:7)
at androidx.test.espresso.ViewInteraction$1.call(ViewInteraction.java:1)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

@montwell
Copy link

montwell commented Mar 1, 2023

My issue was resolved using 3.5.0-alpha04.

@brettchabot
Copy link
Collaborator

Thanks for the additional reports. Many apologies for the delay here.
The D8 team has submitted a workaround fix for this issue. https://issuetracker.google.com/271408544 has the details.

In addition I hope to release a espresso 3.6.0-alpha01 next week which will be built with bazel + javac 11, and also will therefore not be subject to this problem.

@sgjesse
Copy link

sgjesse commented Mar 3, 2023

The patch has landed and have been backported to 8.0.33, 4.0.55 and 3.3.91 for AGP 8.0, 7.4 and 7.3 respectively. To use a specific R8 version merge the following into settings.gradle or settings.gradle.kts:

pluginManagement {
    buildscript {
        repositories {
            mavenCentral()
            maven {
                url = uri("https://storage.googleapis.com/r8-releases/raw")
            }
        }
        dependencies {
            classpath("com.android.tools:r8:8.1.4-dev")
        }
    }
}

@brettchabot
Copy link
Collaborator

espresso 3.6.0-alpha01 is out now

@tneginareb
Copy link

Our team is facing new issues related to androidx.tracing. Anyone else?

@AlexZezekalo
Copy link

maybe downgrade to fix temporary that issue? What's version below 3.4?

@gandrewstone
Copy link

3.5.1 and 3.6.0 alpha04 are failing for me after a few test scenarios. 3.4.0 is working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants