Today encountered this problem when importing someone else's project.
1, open Termianl, enter the command gradlew compileDebug --stacktrace
after that, it will show some information about specific errors.
2, I encountered an error message
Error occurred during initialization of VM
Could not reserve enough space for 1572864KB object heap
In the gradle.properties
org.gradle.jvmargs=-Xmx1024m
Changed
org.gradle.jvmargs=-Xmx512m