0

I want to run a flutter application that I wrote on Visual Studio Code on the device. However, when I do this, I always get the following error. Normally this wouldn't happen, it's just starting to happen. I'm not entirely sure what I should do.

FAILURE: Build failed with an exception.
       
* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> Kotlin could not find the required JDK tools in the Java installation '/usr/lib/jvm/oracle-java8-jre-amd64' used by Gradle. Make sure Gradle is running on a JDK, not JRE.
   
* 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
       
BUİLD FAILED in 45s
Exception: Gradle task assembleDebug failed with exit code 1
  • OS : Ubuntu
  • Mobile Device : Samsung J500F
  • Android Version : 6.0.1

2 Answers 2

1

You need to have installed a JDK. Depending on which version of Ubuntu you should just be able to do sudo apt install openjdk-8-jre-headless

That said, I would target a higher Java version, if I were you, maybe 11?

Either way, if you look at the path your JRE is in, it's '/usr/lib/jvm/oracle-java8-jre-amd64'

You don't want to be using the regular JRE to build/run your application. You want to build and run with openjdk. That's why your error message says,

"Make sure Gradle is running on a JDK, not JRE."

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for the answer
0

The message Execution failed for task ':app:compileDebugKotlin' and the Gradle issue indicate that your problem is not about Flutter but about Android, and more precisely about the lack of JDK (which allows to execute Java and Kotlin code). To solve this problem, it is necessary to review the configuration of your project.

I advise you if possible to use Android Studio, an IDE recommended by Android developers and that will make things much easier with Android and Flutter.

This article from the official Android documentation and this one from JetBrains should help you solve your problem.

You can install Android Studio from snap store or zip

1 Comment

Thank you for the answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.