Repository navigation
[various] Update Robolectric to 4.17 - #13041
Conversation
…n unit tests JDK 17+ enforces strong encapsulation of JDK internals, so Robolectric requires a set of --add-opens flags on the unit test JVM (https://robolectric.org/getting-started/#running-with-java-17-and-higher). The current Robolectric 4.16 does not need them for these tests, but starting with Robolectric 4.17 the per-test environment setup (AndroidTestEnvironment.setUpApplicationState -> ApplicationSharedMemory.create -> FileDescriptorInterceptor) reflects into jdk.internal.access.SharedSecrets and fails with: IllegalAccessException: ... module java.base does not export jdk.internal.access to unnamed module Add the flag set recommended by Robolectric to the existing testOptions.unitTests.all block of every plugin that uses Robolectric, ahead of the 4.17 bump. These args only affect each plugin's own unit test JVM; they are not part of the published plugin. Plugins: camera_android, camera_android_camerax, file_selector_android, google_maps_flutter_android, image_picker_android, in_app_purchase_android, local_auth_android, shared_preferences_android, url_launcher_android, video_player_android.
Robolectric 4.17 adds support for Android SDK 37 (API 37), which is needed before plugins can move their compile/target SDK to 37. This depends on the --add-opens JVM arguments added in the previous commit; without them Robolectric 4.17 fails most tests on JDK 17+. video_player_android additionally needs jsr305 on the unit test compile classpath. Robolectric 4.17 added a @javax.annotation.concurrent.GuardedBy annotation to ShadowView (the superclass of ShadowSurfaceView, which PlatformVideoViewTest uses), but doesn't declare a dependency on jsr305, the library that defines it. javac emits a -Xlint:classfile warning when a referenced class carries an annotation it can't resolve, and the example app compiles the plugin with -Xlint:all -Werror, so the test compile fails without it.
Keeps the example apps' Robolectric version in sync with the plugins. The video_player_android example app has its own unit tests, so it also gets Robolectric's recommended --add-opens JVM arguments, which 4.17 requires on JDK 17+.
Generated with:
dart run script/tool/bin/flutter_plugin_tools.dart update-release-info \
--version=minimal --base-branch=<PR base> \
--changelog="Updates Robolectric to 4.17 and adds the JVM arguments it requires for unit tests."
The video_player entry (example-app-only change, NEXT section) was
reworded by hand since that example gets no new JVM arguments.
|
It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group. |
There was a problem hiding this comment.
Code Review
This pull request updates Robolectric to version 4.17 and adds the required JVM arguments (--add-opens) for JDK 17+ compatibility across multiple Android packages and their examples. It also adds the jsr305 dependency to video_player_android to resolve a compiler warning. Feedback on the changes notes that the video_player example app's build.gradle.kts updates Robolectric to 4.17 but is missing the corresponding JVM arguments, which will cause unit test failures on JDK 17+.
# Conflicts: # packages/camera/camera_android_camerax/CHANGELOG.md # packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md # packages/google_maps_flutter/google_maps_flutter_android/pubspec.yaml # packages/video_player/video_player_android/example/android/app/build.gradle.kts
|
Both have merged |
…er#193711) flutter/packages@d5ec6db...5620e65 2026-10-02 36861262+QuncCccccc@users.noreply.github.com [material_ui] Migrate M3 Menu template to use new gen_defaults (flutter/packages#13057) 2026-10-02 44747303+theprantadutta@users.noreply.github.com [material_ui] Repaint NavigationIndicator when the selection changes without pointer input (flutter/packages#13010) 2026-10-01 tarrinneal@gmail.com [tool] Use flutter pub for packages that depend on jni (flutter/packages#13087) 2026-10-01 72785248+fkrhzbllh@users.noreply.github.com [material_ui] Migrate M3 snackbar defaults to new gen_defaults (flutter/packages#13009) 2026-10-01 engine-flutter-autoroll@skia.org Manual roll Flutter (stable) from 6a19cca to 5fc3468 (6 revisions) (flutter/packages#13105) 2026-10-01 engine-flutter-autoroll@skia.org Manual roll Flutter from d649d2b to e89fd0a (27 revisions) (flutter/packages#13104) 2026-10-01 70351342+burakJs@users.noreply.github.com [webview_flutter] Add gesture blocking policy to WebKitWebViewWidgetCreationParams (flutter/packages#12496) 2026-10-01 21270878+elliette@users.noreply.github.com [material_ui] Update Material tokens to Material version 38.2.83 (flutter/packages#13082) 2026-10-01 dkwingsmt@users.noreply.github.com [material_ui] Migrate MaterialApp API doc snippets to {@example} and add unit tests (batch 6) (flutter/packages#13021) 2026-10-01 dkwingsmt@users.noreply.github.com [material_ui] Migrate AppBar, SliverAppBar, BottomAppBar, and Scaffold API doc snippets to {@example} (batch 7) (flutter/packages#13023) 2026-10-01 jessiewong401@gmail.com [various] Update Robolectric to 4.17 (flutter/packages#13041) 2026-10-01 tarrinneal@gmail.com [pigeon] pin native interop related dev deps and update some docs (flutter/packages#13103) 2026-10-01 stuartmorgan@google.com [tool] Add more documentation (flutter/packages#13063) If this roll has caused a breakage, revert this CL and set the roller to dry run mode using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC flutter-ecosystem@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Updates test dependencies to Robolectric 4.17.
Added a bunch of flags because JDK 17+ blocks reflective access to JDK internals by default. Starting with 4.17, Robolectric's test environment setup reflects into jdk.internal.access, so these are required. This is the flag set
recommended by Robolectric, see https://robolectric.org/getting-started/#running-with-java-17-and-higher.
Partially Addresses flutter/flutter#193404
Pre-Review Checklist
[shared_preferences]///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2