for my case it was because some sdk licenses were not accepted. i figured it out when i ran the gradlew through the command line. the link below shows you how to accept all the licenses through sdkManager tool.
You have not accepted the license agreements of the following SDK components