1

While running the emulator code in Android Studio, I get

CreateProcess error=2, The system cannot find the file specified.

A brief snippet of the log has a section of message as below:

"Caused by: java.io.IOException: Cannot run program "C:\Users\m1013408\Downloads_f7df51368a33044a6377fe1c47947f07_SharingApp_elastic_search_starter\SharingApp_elastic_search_starter\caches\transforms-1\files-1.1\aapt2-3.3.2-5309881-windows.jar\f7d91a5259c0c7b5bbb75c07120738d5\aapt2-3.3.2-5309881-windows\aapt2.exe": CreateProcess error=2, The system cannot find the file specified"

The program, whose path is mentioned above, is available in the location when manually searched for. Apparently then I am wondering why is the system not able to find the file specified? I am however not sure if this is the cause of the error.

Additional info -

I have JDK 7 in my system and have provided the JDK's path in the project structure as well. Some of the solutions suggested this could be an issue. However, it does not seem so. I get this error despite the JDK path being mentioned correctly.

Look forward to a solution.

Zoe
  • 27,060
  • 21
  • 118
  • 148

1 Answers1

0

This is because your aapt2.exe path is already more than 260 characters. Your current path length is 261 characters. This is a limitation in Windows, see Why does the 260 character path length limit exist in Windows? for details.

You need to move your Gradle cache closer to the root of your drive to avoid the limitation.

Izabela Orlowska
  • 7,431
  • 2
  • 20
  • 33
ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96
  • Also, the Python installer has an option to disable it. Not sure how it works though, but it might be worth looking into. It's at least theoretically possible to disable it/bypass it – Zoe Mar 30 '19 at 08:33
  • thanks Zoe for the suggested workaround. However, can you also help me on how to move the Gradle cache. I was checking in the android studio, but could not figure out if there is an option to move the gradle cache in the studio. Further the file is on the root drive only. Which root drive are you suggesting me to get the gradle cache closer to. Sorry If I sound naive. I am new to programming – Aravind Rangarajan Apr 01 '19 at 13:42