Error using com.google.gms: google-services: 4.3.4

Viewed 3468

I am trying to connect Firebase project to my app. But when I add "classpath" com.google.gms: google-services: 4.3.4" AS is giving this error:

Cause: unable to find valid certification path to requested target

What should I do?

build.gradle:

  apply plugin: 'com.android.application'
  apply plugin: 'com.google.gms.google-services'

 buildscript {
repositories {
    google()
    jcenter()
}
dependencies {
    classpath "com.android.tools.build:gradle:4.0.1"
    classpath 'com.google.gms:google-services:4.3.3'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

allprojects {
    repositories {
        google()
        jcenter()
}
}

 task clean(type: Delete) {
 delete rootProject.buildDir
 }

build.gradle(app):

 android {
compileSdkVersion 30
buildToolsVersion "29.0.3"

defaultConfig {
    applicationId "com.vogella.findpeople"
    minSdkVersion 14
    targetSdkVersion 30
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
}


 dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'


implementation 'com.google.firebase:firebase-auth:19.4.0'
implementation 'com.google.firebase:firebase-database:19.5.0'
}
3 Answers

The link I flagged should work for you. Try this

classpath 'com.google.gms:google-services:4.3.3'

Replace your classpath with this and resync.

Try to move your apply plugin: lines to the app build.gradle file instead of the project one

I had a similar problem with regard to adding this classpath 'com.google.gms:google-services:4.3.4' but it seems like I had a bad internet connection, and when I had a strong internet connection, this error occurred, enter image description here

it also occurred to me that that error was also due to a poor internet connection, after I fixed that then this error occurred, enter image description here

this was because I included this implementation platform('com.google.firebase:firebase-bom:26.0.0') in build.gradle file within the app directory. So I commented it out and now I was able to run the flutter app in my android device. Like this, enter image description here

Related