Skip to content

Add java/gradle check when gradle crashes - #189997

Merged
auto-submit[bot] merged 14 commits into
flutter:masterfrom
mboetger:java-gradle-check
Jul 31, 2026
Merged

Add java/gradle check when gradle crashes#189997
auto-submit[bot] merged 14 commits into
flutter:masterfrom
mboetger:java-gradle-check

Conversation

@mboetger

@mboetger mboetger commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Adds a check for Java/Gradle compatibility after gradle crashes. If the two are incompatible, Gradle can't even start up to run the DependencyVersionChecker.kt - so it throws a cryptic error.

Partially address: #189780

Before

❯ flutter config --jdk-dir=/opt/homebrew/opt/openjdk@25/libexec/openjdk.jdk/Contents/Home
Setting "jdk-dir" value to "/opt/homebrew/opt/openjdk@25/libexec/openjdk.jdk/Contents/Home".

You may need to restart any open editors for them to read new settings.
❯ flutter build apk
WARNING: A restricted method in java.lang.System has been called
WARNING: java.lang.System::load has been called by net.rubygrapefruit.platform.internal.NativeLibraryLoader in an unnamed module (file:/Users/boetger/.gradle/wrapper/dists/gradle-8.14-all/c2qonpi39x1mddn7hk5gh9iqj/gradle-8.14/lib/native-platform-0.22-milestone-28.jar)
WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module
WARNING: Restricted methods will be blocked in a future release unless native access is enabled


FAILURE: Build failed with an exception.

* What went wrong:
25.0.4

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 321ms

After

❯ flutter config --jdk-dir=/opt/homebrew/opt/openjdk@25/libexec/openjdk.jdk/Contents/Home
Setting "jdk-dir" value to "/opt/homebrew/opt/openjdk@25/libexec/openjdk.jdk/Contents/Home".
You may need to restart any open editors for them to read new settings.
❯ flutter build apk
Gradle build failed due to Java/Gradle incompatibility.
The Java version used for the build is 25.0.4, which is incompatible with Gradle 8.14.
To fix this, you can either:
  1. Upgrade your project's Gradle version (typically in gradle-wrapper.properties to a version matching the range: compatible Gradle versions for Java 25.0.4 are 9.1.0
  to newer).
  2. Use a different Java version for Flutter by running `flutter config --jdk-dir=<path>`.
Alternatively, you can bypass this check using "--android-skip-build-dependency-validation".

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

@github-actions github-actions Bot added tool Affects the "flutter" command-line tool. See also t: labels. team-android Owned by Android platform team labels Jul 24, 2026
@mboetger
mboetger force-pushed the java-gradle-check branch from 684a74d to 5fc04d6 Compare July 24, 2026 18:27
@mboetger
mboetger marked this pull request as ready for review July 24, 2026 18:34
@mboetger
mboetger requested a review from a team as a code owner July 24, 2026 18:34
@mboetger
mboetger requested review from gmackall and removed request for a team July 24, 2026 18:34

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a pre-flight validation check in AndroidGradleBuilder to ensure Java and Gradle version compatibility before invoking Gradle, throwing a ToolExit with actionable recommendations if an incompatibility is found. It also adds corresponding unit tests to verify this validation behavior and the ability to bypass it. Feedback focuses on improving the grammar of the generated error message when no maximum compatible Gradle version is defined, along with updating the associated test expectations.

Comment thread packages/flutter_tools/lib/src/android/gradle.dart Outdated
@mboetger mboetger added the CICD Run CI/CD label Jul 24, 2026
Comment thread packages/flutter_tools/lib/src/android/gradle.dart Outdated
@mboetger
mboetger requested a review from gmackall July 24, 2026 19:28
Comment thread packages/flutter_tools/lib/src/android/gradle.dart Outdated
gmackall
gmackall previously approved these changes Jul 30, 2026
@mboetger mboetger added autosubmit Merge PR when tree becomes green via auto submit App and removed autosubmit Merge PR when tree becomes green via auto submit App labels Jul 30, 2026
@auto-submit

auto-submit Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/189997, because - The status or check suite Dashboard Checks has failed. Please fix the issues identified (or deflake) before re-applying this label.

@gmackall gmackall left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rerelgtm

@gmackall gmackall added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 30, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Jul 30, 2026
Merged via the queue into flutter:master with commit 52ac893 Jul 31, 2026
22 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jul 31, 2026
@mboetger mboetger added the cp: merge-to-beta Cherry-picks that should be merged to beta label Jul 31, 2026
@mboetger mboetger added cp: beta cherry pick this pull request to beta release candidate branch and removed cp: merge-to-beta Cherry-picks that should be merged to beta labels Jul 31, 2026
@flutteractionsbot

Copy link
Copy Markdown
Contributor

Failed to create CP due to merge conflicts.
You will need to create the PR manually. See the cherrypick wiki for more info.

auto-submit Bot pushed a commit that referenced this pull request Aug 4, 2026
## Impacted Users
Anybody attempting to build an Android app with a Gradle incompatible with their JDK.  This is now an issue as the RC for Android Studio is JDK 25 which does not work with Gradle 8.14.

## Impact Description
The `flutter build apk` command will crash without a good error message. 

## Workaround
Change your JDK or Gradle version.

## Risk
Low

## Test Coverage
Good

## Validation Steps
1. Set the JDK: `flutter config --jdk-dir=/opt/homebrew/opt/openjdk@25/libexec/openjdk.jdk/Contents/Home`
2. Build the APK: `flutter build apk`
3. Verify the error message (seen below)

Before
```
❯ flutter config --jdk-dir=/opt/homebrew/opt/openjdk@25/libexec/openjdk.jdk/Contents/Home
Setting "jdk-dir" value to "/opt/homebrew/opt/openjdk@25/libexec/openjdk.jdk/Contents/Home".

You may need to restart any open editors for them to read new settings.
❯ flutter build apk
WARNING: A restricted method in java.lang.System has been called
WARNING: java.lang.System::load has been called by net.rubygrapefruit.platform.internal.NativeLibraryLoader in an unnamed module (file:/Users/boetger/.gradle/wrapper/dists/gradle-8.14-all/c2qonpi39x1mddn7hk5gh9iqj/gradle-8.14/lib/native-platform-0.22-milestone-28.jar)
WARNING: Use --enable-native-access=ALL-UNNAMED to avoid a warning for callers in this module
WARNING: Restricted methods will be blocked in a future release unless native access is enabled

FAILURE: Build failed with an exception.

* What went wrong:
25.0.4

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

BUILD FAILED in 321ms
```

After
```
❯ flutter config --jdk-dir=/opt/homebrew/opt/openjdk@25/libexec/openjdk.jdk/Contents/Home
Setting "jdk-dir" value to "/opt/homebrew/opt/openjdk@25/libexec/openjdk.jdk/Contents/Home".
You may need to restart any open editors for them to read new settings.
❯ flutter build apk
Gradle build failed due to Java/Gradle incompatibility.
The Java version used for the build is 25.0.4, which is incompatible with Gradle 8.14.
To fix this, you can either:
  1. Upgrade your project's Gradle version (typically in gradle-wrapper.properties to a version matching the range: compatible Gradle versions for Java 25.0.4 are 9.1.0
  to newer).
  5. Use a different Java version for Flutter by running `flutter config --jdk-dir=<path>`.
Alternatively, you can bypass this check using "--android-skip-build-dependency-validation".
```
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Aug 9, 2026
…12401)

Manual roll Flutter from 2757a77a73df to e52f01c920ad (47 revisions)

Manual roll requested by stuartmorgan@google.com

flutter/flutter@2757a77...e52f01c

2026-07-31 jason-simmons@users.noreply.github.com [Impeller] Execute PipelineCompileQueue jobs in the order that they were added (flutter/flutter#190262)
2026-07-31 engine-flutter-autoroll@skia.org Roll Packages from 7d17fc8 to 5351d8c (5 revisions) (flutter/flutter#190351)
2026-07-31 engine-flutter-autoroll@skia.org Roll Skia from dcbd015c9646 to 7ef86a5b0eb9 (4 revisions) (flutter/flutter#190347)
2026-07-31 jason-simmons@users.noreply.github.com [Impeller] Do not acquire an unneeded image in KHRSwapchainVK if the swapchain must be recreated due to a size change (flutter/flutter#190116)
2026-07-31 jason-simmons@users.noreply.github.com Remove the --enable-serial-gc engine flag (flutter/flutter#190310)
2026-07-31 36861262+QuncCccccc@users.noreply.github.com Migrate platform_channel_swift example to material_ui (flutter/flutter#190308)
2026-07-31 chris@bracken.jp macOS: Set static text accessibility role for read-only text fields (flutter/flutter#190330)
2026-07-31 engine-flutter-autoroll@skia.org Roll Dart SDK from 96f49fc43f59 to c3acfc2479f6 (1 revision) (flutter/flutter#190336)
2026-07-31 engine-flutter-autoroll@skia.org Roll Skia from 07f08414dd66 to dcbd015c9646 (1 revision) (flutter/flutter#190333)
2026-07-31 zhongliu88889@gmail.com [web] Autofill all AutofillGroup fields in semantics mode (flutter/flutter#187108)
2026-07-31 chris@bracken.jp iOS: Configure test task runner thread at display QoS (flutter/flutter#190283)
2026-07-31 engine-flutter-autoroll@skia.org Roll Skia from a1109355de78 to 07f08414dd66 (5 revisions) (flutter/flutter#190328)
2026-07-31 chris@bracken.jp Support reduceMotion accessibility feature in MediaQuery (flutter/flutter#190287)
2026-07-30 engine-flutter-autoroll@skia.org Roll Dart SDK from 43f7de5f4977 to 96f49fc43f59 (4 revisions) (flutter/flutter#190312)
2026-07-30 mu7ammadkamel@hotmail.com fix: text selection two handles directionality. (flutter/flutter#179928)
2026-07-30 matt.boetger@gmail.com Add java/gradle check when gradle crashes (flutter/flutter#189997)
2026-07-30 41765610+ahyangnb@users.noreply.github.com [Impeller] Add filterQuality support to ImageFilter.shader (flutter/flutter#188544)
2026-07-30 dkwingsmt@users.noreply.github.com [flutter/flutter] Migrate multiple_windows example to material_ui (flutter/flutter#190313)
2026-07-30 engine-flutter-autoroll@skia.org Roll Skia from 50cf67910462 to a1109355de78 (6 revisions) (flutter/flutter#190306)
2026-07-30 31859944+LongCatIsLooong@users.noreply.github.com Migrate swift xctests to Swift testing tests (flutter/flutter#187801)
2026-07-30 36861262+QuncCccccc@users.noreply.github.com Migrates the platform_channel example to material_ui (flutter/flutter#190253)
2026-07-30 chris@bracken.jp iOS: Drop unnecessary @mainactor from VSyncClientTests (flutter/flutter#190285)
2026-07-30 evanwall@buffalo.edu Add nullptr check to isOpaque (flutter/flutter#189796)
2026-07-30 bdero@google.com [Flutter GPU] Bind uniforms and textures by cached reflection index (flutter/flutter#189820)
2026-07-30 jmccandless@google.com Migrate layers example to material_ui (flutter/flutter#190237)
2026-07-30 bernaferrari2@gmail.com Add `ShapeBorder` hit test fast paths (flutter/flutter#187962)
2026-07-30 codefu@google.com ci: mac-must-wait part duex (flutter/flutter#190295)
2026-07-30 engine-flutter-autoroll@skia.org Roll Skia from 491301f393d1 to 50cf67910462 (3 revisions) (flutter/flutter#190294)
2026-07-30 engine-flutter-autoroll@skia.org Roll Packages from dd11626 to 7d17fc8 (1 revision) (flutter/flutter#190293)
2026-07-30 engine-flutter-autoroll@skia.org Roll Skia from 177de1940bf2 to 491301f393d1 (1 revision) (flutter/flutter#190279)
2026-07-30 engine-flutter-autoroll@skia.org Roll Skia from b8bda91f02db to 177de1940bf2 (5 revisions) (flutter/flutter#190272)
2026-07-30 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from J8rVTlBnjnUpuHYk3... to _J8wM3kyQpLN9wvRD... (flutter/flutter#190273)
2026-07-30 engine-flutter-autoroll@skia.org Roll Skia from 78afc18c9ba0 to b8bda91f02db (3 revisions) (flutter/flutter#190268)
2026-07-30 154381524+flutteractionsbot@users.noreply.github.com Revert: Split the platform and cpuArch part of TargetPlatform (flutter/flutter#190258)
2026-07-30 developeryusuf@icloud.com Return null from RenderProxyBoxMixin.computeDryBaseline when the child has no baseline (flutter/flutter#189723)
2026-07-30 engine-flutter-autoroll@skia.org Roll Skia from 6fea713d32ec to 78afc18c9ba0 (4 revisions) (flutter/flutter#190257)
2026-07-30 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#190259)
2026-07-29 brackenavaron@gmail.com [cross imports] Check examples cross imports (flutter/flutter#187662)
2026-07-29 codefu@google.com ci: mac verify binaries still has to wait on linux_host_engine (flutter/flutter#190239)
2026-07-29 30870216+gaaclarke@users.noreply.github.com Adds analytics to macos impeller opt in/out (flutter/flutter#190220)
2026-07-29 engine-flutter-autoroll@skia.org Roll Skia from 0f35bba4945c to 6fea713d32ec (6 revisions) (flutter/flutter#190230)
2026-07-29 chris@bracken.jp iOS: Fix Swift warning in TracingTests (flutter/flutter#190203)
2026-07-29 matt.boetger@gmail.com Convert all gradle-wrapper.properties in /dev to use distribution 'bin' (flutter/flutter#190226)
2026-07-29 engine-flutter-autoroll@skia.org Roll Packages from 3e63635 to dd11626 (11 revisions) (flutter/flutter#190216)
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD cp: beta cherry pick this pull request to beta release candidate branch team-android Owned by Android platform team tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants