In my case, I have used:
Assets > External Dependency Manager > Android Resolver > Force Resolve
to fix it (it shows the popup "Enable Android Gradle Templates?" where you can manually click Resolve, before starting building the application).