I stored the glsl files in android -> assets -> shaders directory, but when I run the app, an error is displayed:

Error:Gradle: Execution failed for task ':android:mergeDebugAssets'.
Error: java.io.FileNotFoundException: ...android\assets\shaders (Access is denied)

But the problem goes away if I put those files in assets root folder. Can I not store shader files in asset subdirectories? Using Gdx v1.9.3.

EDIT: The issue is not there when running on Desktop, but only on Android. Didn't check others.

UPDATE: Apparently the issue got resolved today. I didn't make any changes but it's working now!

  • \$\begingroup\$ What code are you using? Using Gdx.files.internal("shaders/<filename>.glsl") works for me... \$\endgroup\$ – JDSweetBeat Jul 13 '16 at 15:19
  • \$\begingroup\$ Yes, that's how I'm using too. But that error message I mentioned gets thrown. \$\endgroup\$ – WeirdElfB0y Jul 13 '16 at 18:02
  • \$\begingroup\$ Did you use the setup application to target Android initially? If not, you might have made a mistake (logical or otherwise) in the gradle setup. If that is not the problem the only other thing I know to tell you (without looking at the code that causes the exception) is to check for typos and make sure your Android project is configured correctly. \$\endgroup\$ – JDSweetBeat Jul 13 '16 at 19:44
  • \$\begingroup\$ Yes I did that. I selected all target platforms during setup. I will check android gradle file again for any typos. This happens when running on Android, no problem in Desktop. \$\endgroup\$ – WeirdElfB0y Jul 14 '16 at 5:52
  • \$\begingroup\$ Apparently the issue got resolved today. I didn't make any changes but it's working now! \$\endgroup\$ – WeirdElfB0y Jul 14 '16 at 6:24

I assume you use Android Studio or IntelliJIdea (don't know how Eclipse works).

These errors happen because of Windows administrative permissions. All you have to do is to open the parent folder (this one where your 'access denied' folder is in) in a windows file explorer. You need to rename the folder to anything you want and name it back with a previous name. If it was folder named shaders, rename it to shaders2 and go back with shaders. IntelliJ/Android Studio will refresh the project itself and it will work.

This is caused by adding files directly to the project, but not to the folder itself ;) Happens to me on Windows10 when running Android Emulator or a normal mobile phone plugged in.

| improve this answer | |
  • \$\begingroup\$ Thank you. That explains why it got solved automatically the next time I opened the project. \$\endgroup\$ – WeirdElfB0y Nov 30 '16 at 10:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.