Been fighting this for two days now. Part of me thinks maybe when I updated my M1 Mac or when I ran flutter icon script that its messing up my java versions.
I get this error in my build.gradle
The supplied phased action failed with an exception.
A problem occurred configuring root project 'android'.
A problem occurred evaluating root project 'android'.
A problem occurred configuring project ':app'.
Build file '/Users/mike_jones/Documents/development/projects/aridromos/android/app/build.gradle' line: 2
An exception occurred applying plugin request [id: 'com.android.application']
Failed to apply plugin 'com.android.internal.application'.
Android Gradle plugin requires Java 17 to run. You are currently using Java 11.
Your current JDK is located in /Library/Java/JavaVirtualMachines/temurin-11.jdk/Contents/Home
You can try some of the following options:
- changing the IDE settings.
- changing the JAVA_HOME environment variable.
- changing `org.gradle.java.home` in `gradle.properties`.Java(0)
But in my terminal VS code I get this when I check versions:
mike_jones@macbookpro android % echo $JAVA_HOME
/opt/homebrew/opt/openjdk@17
mike_jones@macbookpro android % java -version
openjdk version "17.0.14" 2025-01-21
OpenJDK Runtime Environment Homebrew (build 17.0.14+0)
OpenJDK 64-Bit Server VM Homebrew (build 17.0.14+0, mixed mode, sharing)
mike_jones@macbookpro android % ./gradlew printJavaEnv
> Task :app:printJavaEnv
JAVA_HOME: /opt/homebrew/opt/openjdk@17
java.version: 17.0.14
java.home: /opt/homebrew/Cellar/openjdk@17/17.0.14/libexec/openjdk.jdk/Contents/Home
BUILD SUCCESSFUL in 838ms
5 actionable tasks: 1 executed, 4 up-to-date
mike_jones@macbookpro android %
Fluttor Doctor Output:
[âś“] Flutter (Channel stable, 3.27.0, on macOS 15.3 24D60 darwin-arm64, locale en-US)
• Flutter version 3.27.0 on channel stable at /Users/mike_jones/Documents/development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 8495dee1fd (2 months ago), 2024-12-10 14:23:39 -0800
• Engine revision 83bacfc525
• Dart version 3.6.0
• DevTools version 2.40.2
[âś“] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/mike_jones/Library/Android/sdk
• Platform android-35, build-tools 34.0.0
• ANDROID_HOME = /Users/mike_jones/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 21.0.5+-12932927-b750.29)
• All Android licenses accepted.
[âś“] Xcode - develop for iOS and macOS (Xcode 16.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 16C5032a
• CocoaPods version 1.15.2
[âś“] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[âś“] Android Studio (version 2024.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 21.0.5+-12932927-b750.29)
[âś“] VS Code (version 1.97.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.104.0
[âś“] Connected device (5 available)
• sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64 • Android 13 (API 33) (emulator)
• Michael’s iPad (mobile) • 00008103-000C650902B8A01E • ios • iOS 18.3.1 22D72
• macOS (desktop) • macos • darwin-arm64 • macOS 15.3 24D60 darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 15.3 24D60 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 133.0.6943.127
[âś“] Network resources
• All expected network resources are available.
No idea why its not working or sticking.