From fe667560d0f67b43a63f82adc15ec205beb49cad Mon Sep 17 00:00:00 2001 From: ibaker Date: Thu, 18 May 2023 10:01:14 +0000 Subject: [PATCH] Upgrade to Robolectric 4.10.3 We originally upgraded to 4.10 in https://github.com/androidx/media/commit/889f435a49eff9dc9fb516bd0bee85c1ca7a3f7d However I saw `ShadowActivityThread.reset: ActivityThread not set` errors when running any Robolectric test, so I downgraded to 4.8.1: https://github.com/androidx/media/commit/85e449cd8780b0c3012bfdbab19ea35fae2ee961 Nobody else on the team was seeing the same error with 4.10, so it was something different about my local setup. The error was actually masking a different problem (see discussion: https://github.com/robolectric/robolectric/issues/8160). Upgrading to 4.10.1 made the underlying error clear: ``` java.lang.UnsatisfiedLinkError: /tmp/libconscrypt_openjdk_jni-linux-x86_6416831044223480000.so: libstdc++.so.6: cannot open shared object file: No such file or directory ``` This was then fixed by changing my 'Gradle JDK' value in Android Studio from a JDK 11-based value to a 17-based one. If others see the same `UnsatisfiedLinkError` when running the tests locally they should check their Gradle JDK setting in Android Studio. However there was **another** problem with 4.10 that **did** affect everyone: some tests in `ExoPlayerTest` would fail with time outs or assertion failures related to clock advancement. After some investigation in https://github.com/robolectric/robolectric/issues/8187 it turns out this is because there's lots of unrelease `Player` instances in `ExoPlayerTest`, which keep lots of active `HandlerThreads` that then have to all be woken up by Robolectric. 4.10.3 has a fix that mitigates this, so we can upgrade immediately - but we should also release all the `Player` instances in `ExoPlayerTest` (it might speed up test execution too). PiperOrigin-RevId: 533068395 --- constants.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/constants.gradle b/constants.gradle index bfac06c19b..2b3c79c0fe 100644 --- a/constants.gradle +++ b/constants.gradle @@ -29,7 +29,7 @@ project.ext { // https://cs.android.com/android/platform/superproject/+/master:external/guava/METADATA guavaVersion = '31.1-android' mockitoVersion = '3.12.4' - robolectricVersion = '4.8.1' + robolectricVersion = '4.10.3' // Keep this in sync with Google's internal Checker Framework version. checkerframeworkVersion = '3.13.0' checkerframeworkCompatVersion = '2.5.5'