ChatGPT and similar “AI” tools are very good at giving answers that look correct, but pretty bad at giving answers that are correct. You should never ask them about this you don’t know yourself or couldn’t do yourself. You always have to understand what it responded and fix the nonsense it gave you. They are just good at doing things you for which you are too lazy to do yourself (the good lazy, not the bad one) and which you can then iron out yourself.
From the top of my head, I’d say it is not using the Gradle .all but the Kotlin .all which has totally different semantics. Also the Gradle .all you should not use, but instead .configureEach. and you probably need to remove the lambda parameter and use this instead (explicitly or implicitly doesn’t matter).