I am getting a compile error in the following code in Android Studio.
Path fileName = Path.of("demo.txt");
String content = "hello world !!";
Files.writeString(fileName, content);
String actual = Files.readString(fileName);
As 'writeString' and 'readString' were instroduced in Java 11, my first guess was it has something to do with that.
I'm using the latest version of Android Studio and have Java 11 installed. Used to have Java 8 as well but I have deleted that already. I'm certain it is just some setting issue or some stucked cache stuff as in IntelliJ it works fine.
I have tried:
- invalidate cache and restart
- removing the .idea and .gradle folders
- I also let Adroid Studio to download Java 11 for itself and not using the one specified by me.
Any guesses?
Thanks in advance!