0

I wanted to test my flutter app in phone. So I tried to 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 can't find Java. Because C:\Program Files\Java\jre1.8.0_51\bin path is empty. I tried to uninstall and reinstall Java, but result is the same. How can I solve this and build apk for test in my phone?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
CanKURT
  • 23
  • 4

1 Answers1

1

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

  • That is solved java error. But i take new error when build apk. FAILURE: Build failed with an exception. * Where: Build file 'C:\Users\Can Ahmet\StudioProjects\myapp\myapp\android\app\build.gradle' line: 26 Should i ask new questions? Do you have idea? – CanKURT Dec 23 '22 at 19:00
  • @CanKURT you should generate new question with code for "bild.gradle" file and complete error logs. – Abdul Rafay Dec 25 '22 at 05:42