error
FAILURE: Build failed with an exception. * What went wrong: Could not initialize class org.codehaus.groovy.reflection.ReflectionCache * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. * Get more help at https://help.gradle.org
solution
go to the gradle-wrapper.properties located under android>>gradle/wrapper
and change the gradle version to 6.3 (in my case it was 5.5)
It was like this:
distributionUrl=https://services.gradle.org/distributions/gradle-5.5-all.zip
Changed to this:
distributionUrl=https://services.gradle.org/distributions/gradle-6.3-all.zip
Compile and it should work.```
source:
https://github.com/gradle/gradle/issues/10248