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
You should have at least one activity that looks something like this:
if this not working for you then apply File -> Invalidate Caches / Restart once again