Hi, Thanks for the response. I was able to fix this by altering my Java version to 11 and using AGP android upgrade assistant
using these dependencies:
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21")
// https://mvnrepository.com/artifact/com.android.tools.build/gradle
classpath("com.android.tools.build:gradle:8.1.0")
}
These plugin versions:

and this in gradle-wrapper.properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
Then I went to Tools > AGP Upgrade Assistant and pressed run, then it sorted itself out!
Docs for this tool
So take my versions with a pinch of salt.