I just started to get this error this morning. I cant build any of my projects since then. Any solutions how to fix this? Tried Clean Project
and Invalidate Caches and Restart
multiple times. It worked until today.
Found some question about exact same problem that it can be caused by Windows filepath length. All my projects are located in D:\AndroidProjects
folder. It is not long path.
This error is sometimes replaced by Error running 'app': Default Activity not found
UPDATE: Error is still appearing more frequently now. I just have to try and build the project 20 times in a row and out of nowhere it is working 21nd time. This is some bug in recent Android Studio update. Other coworkers having same problem on Windows and macOS.
Its something with java path:
java.io.IOException: Cannot run program "C:\Program Files\Android\Android Studio\jre\jre\bin\java": CreateProcess error=206, The filename or extension is too long
Below is the only solution worked for me.
I know this is temporary, but this is reliable, so saves our time.
[Note:
I noticed that it happens if we don't restart our computer for long time. I usually hibernate/resume. That may be the root cause.It happens even if we restart daily. :( ]