I am adding firebase to my android application. After adding dependecies `classpath 'com.google.gms:google-services:4.3.0'` and implementation `'com.google.firebase:firebase-database:18.0.1'` and plugins that is apply `plugin: 'com.google.gms.google-services'` and trying to sync it brings an "Apply script build.gradle" error

I have updated my google repositories and have a good internet connection

```
apply plugin: 'com.google.gms.google-services' 

dependencies {
        classpath 'com.android.tools.build:gradle:4.2.1'
        classpath 'com.google.gms:google-services:4.3.0'}`
dependencies{implementation 'com.google.firebase:firebase-database:18.0.1'}

```

I expected a successful sync after adding the dependencies and applying plugins but an error occured