Home > Mobile >  I can't build apk flutter app. Java Error: The supplied javaHome seems to be invalid
I can't build apk flutter app. Java Error: The supplied javaHome seems to be invalid

Time:12-24

I wanted to test my flutter app in phone. So i tried build an apk. I ran this in app files:

flutter build apk --split-per-abi

results:

 Building with sound null safety


FAILURE: Build failed with an exception.

* What went wrong:
The supplied javaHome seems to be invalid. I cannot find the java executable. Tried location: C:\Program Files\Java\jre1.8.0_51\bin\java.exe

* 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
Running Gradle task 'assembleRelease'...                            4,0s
Gradle task assembleRelease failed with exit code 1

If i understood correctly it cant found java. Because C:\Program Files\Java\jre1.8.0_51\bin path is empty. I tried uninstall and reinstall java. But result is same. How can i solve this and build apk for test in my phone?

CodePudding user response:

You have only installed Java JRE (java runtime environment). Install complete java SDK. Add SDK path as JAVA_HOME variable in environment variables.

  • Related