Android Studio gradle does not see file in currect project folder on Windows

Viewed 27

I faced with interesting problem in one of my Android projects in Windows. My project folder is D://workspace/project.

In gradle file in this project I have the following line:

  java.nio.file.Path f = Paths.get('build/some_file_name.dat')
  f.write ...

And this file definitely exists. But I can not compile project because of this error:

Caused by: java.nio.file.NoSuchFileException: build\some_file_name.dat

If I change file path to full path:

  java.nio.file.Path f = Paths.get('D://workspace/project/build/some_file_name.dat')
  f.write ...

it will work correctly, project will be compiled successfully. But I think this is not the best solution and also I need to disable commit changes from this file during every commit, it is not good.

I think, there must be a way to make gradle understand where is file in project folder only by this way: "build/some_file_name.dat".

And also I have noticed, this problem happens only in Windows, in Mac all is okay with it.

Does someone know, how to solve this problem?

1 Answers

The file you are searching "build/some_file_name.dat" is not in the directory where your project is. try to give the accurate path. or make sure you file name doesn't contains any spaces or special character.

Related