Gradle project refresh failed. Android Studio

I get this error when trying to run my App on Android Studio. Does anyone know what the reason could be? Thanks. Gradle 'MyApp' refresh failed. Error:Cannot locate factory for objects of type