Faced the same problem when added Firebase dependencies to my project.
java.lang.SecurityException: Unknown calling package name 'com.google.android.gms'
Solve this by updating installed SDKs: Tool -> SDK Manager -> (in my case) Android API 35 ->
Android SDK Platform 35 and Google Play Intel x86_64 Atom System Image <- updating one of this SDK was solve this exception.