I don't know how I got in to this, but I think the problem is the Java binary path... The path from flutter doctor is different from the one in the Exception. Either when I run existing projects or I create new project and try to run it it still gives the same error.
e: java.io.IOException: Cannot run program "C:\Program Files\Android\Android Studio\jre\jre\bin\java" (in directory "C:\Users\Acer\AppData\Local\kotlin\daemon"): CreateProcess , The system cannot find the file specified FAILURE: Build failed with an exception. * What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
java.io.IOException: Cannot run program "C:\Program Files\Android\Android Studio\jre\jre\bin\java": CreateProcess error=2, The system cannot find the file specified
Flutter doctor -v
[√] Flutter (Channel stable, v1.12.13+hotfix.7, on Microsoft Windows [Version 6.3.9600], locale en-US)
• Flutter version 1.12.13+hotfix.7 at C:\src\flutter
• Framework revision 9f5ff2306b (10 days ago), 2020-01-26 22:38:26 -0800
• Engine revision a67792536c
• Dart version 2.7.0
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at C:\Users\Acer\AppData\Local\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
• All Android licenses accepted.
[√] Android Studio (version 3.5)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 42.1.1
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
[√] VS Code, 64-bit edition (version 1.41.1)
• VS Code at C:\Program Files\Microsoft VS Code
• Flutter extension version 3.8.0
[√] Connected device (1 available)
• Android SDK built for x86 • emulator-5556 • android-x86 • Android 10 (API 29) (emulator)
After this problem I tried to solve it by:
- Upgrading flutter
- Changing the jdk path on Android Studio to Java_Home from: java.io.IOException: Cannot run program CreateProcess error=2, The system cannot find the file specified on android studio.