As a beginner, let me give you two personal recommendations first:
• VSC is mainly a fancy text editor not a fully-fledged IDE. For any serious work, better use a proper IDE like IntelliJ IDEA to save you many headaches
• ChatGPT (and similar tools) are great in giving answers that look correct, but very bad in giving answers that are correct. They are great to do work for you that you could have done yourself but are to lazy to (the good kind of lazy). But you always have to understand what it gave to you, be able to evaluate what it gave to you, and be able to see where it made non-sense and to fix that. Often code those tools give you does not even compile and even if it compiles it does not necessarily do what it is supposed to do and even if it does on the happy path it might not properly handle edge cases. Also they learn from the sources they were given to guess words that appear next, which means it also likes to produce bad practice code it might have seen before.
Regarding your actual question, as far as I understood, you said your Gradle setup is correct, just VSC is misbehaving. If that is the case, you should probably ask in a VSC community eventually.