😊 Hi folks, I hope you're fine these days and you are here because I know you're on your way to finding how to fix the Java Build Failed error in Flutter Framework. Here I'm guiding you to fix the issue in the optimal way. Let's get started! First of all why this error message? Why you're getting this error message is in your Flutter application one of your packages or dependency requires a higher version of Java to execute the package.
Error Message ❌
FAILURE: Build Failed with an exception.
* What went wrong:
Execution failed for task ':package_info_plus:compileDebugJavaWithJavac'.
> error: invalid source release: 17
* 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 20s
This is the error message you're seeing. So how do we fix this Java invalid source release error?
Step 1:
Go to this website and download download Java JDK 17 or higher.
Step 2:
After installing the Java JDK, check whether it was successfully installed or not. to check that, open Command Prompt (cmd) and type java --version command.
if you see this message, then you have successfully installed it. Otherwise, you're getting some message that says "Java is not recognized as an internal command" in cmd. Then you should set the Java JDK bin path to the environment variable and system variable. How to do that? Type "Environment Variables" in the search bar and open it.
After that in the User variable window, you can find a path variable and double-click on it. After that find the Java JDK installation folder copy the path of the bin file and add it here. According to the below screenshot, it is the 2nd record. But the order doesn't matter.
Step 3:
Open your Flutter project in Android Studio and configure the Java version for the project.
File ---> Project Structure ---> Select the path in your Java JDK 17 installed path.
Could not determine the dependencies of task ':photo_manager:compileDebugJavaWithJavac'.
ReplyDelete