Is it ok to add the following robots.txt file to my website?

User-agent: *


That code does absolutely nothing. It won’t do you any harm but there’s no reason to bother

I am getting a message from Google that “Googlebot can’t access your website .com/robots.txt”. will it be solved if I add that code in my site?

If the error message is annoying you then yes, adding that code should get rid of it.

Yes offcourse it will get rid of it by adding that code.