I am using gradle 8.2 with java version 126.96.36.199 when I try to sample project from google it gives me lot of errors. Although I followed same steps but error is appearing. Any help will be highly appreciated.
That guide is heavily outdated.
It uses many legacy things and bad practices, even though it is just 17 lines.
Also, you did not specify what errors you got, so it is hard to guess what problems you have.
But most probably you generated a Kotlin DSL build - which is the default since 8.2 - and then copied the content the guide tells you to put to
build.gradle which would be Groovy DSL to
build.gradle.kts which is Kotlin DSL.
That is like when you paste C# code to a Java file and expect it to work.