Jim Ng
Jim Ng

Reputation: 93

How to solve Could not find com.google.gms:google-services:4.1.0.?

I have encountered this error :

Could not find com.google.gms:google-services:4.1.0.
Required by:
    project :app
Search in build.gradle files

I have tried the other solutions shown on stack overflow from the other people who have asked the same questions:

Could not find com.google.gms:google-services:4.1.0. Searched in the following locations:

Could not find any version that matches com.google.android.gms:play-services-base:[15.0.1,16.0.0)

This is my app build.gradle file:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "sg.edu.singaporetech.teamproject"
        minSdkVersion 26
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation 'com.google.firebase:firebase-core:16.0.8'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.facebook.android:facebook-login:4.41.0'
    implementation 'com.firebaseui:firebase-ui-auth:4.3.1'
    implementation 'com.google.firebase:firebase-auth:16.2.0'
    implementation 'com.google.firebase:firebase-core:16.0.8'
    implementation 'com.google.firebase:firebase-database:16.1.0'
    implementation 'com.google.firebase:firebase-storage:16.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.jjoe64:graphview:4.2.1'
}

apply plugin: 'com.google.gms.google-services'
repositories {
    google()
    jcenter()
    mavenCentral()
    maven { url "https://dl.bintray.com/android/android-tools" }

}

buildscript {
    dependencies {
        classpath 'com.google.gms:google-services:4.1.0'
    }

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

this is my Project build.gradle File

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.3.21'

    repositories {
        google()
        jcenter()
        mavenCentral()
        maven { url "https://dl.bintray.com/android/android-tools" }

    }
    dependencies {
        classpath 'com.google.gms:google-services:4.1.0'
        classpath 'com.android.tools.build:gradle:3.3.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

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

}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://dl.bintray.com/android/android-tools" }


    }

}

I would like this error to be resolved so that I can successfully build my project.

Any help would be much appreciated, thank you.

Upvotes: 1

Views: 8735

Answers (4)

Ameer Mukhat
Ameer Mukhat

Reputation: 39

classpath 'com.google.gms:google-services:4.4.0' use this it worked for me

Upvotes: 0

muneeb
muneeb

Reputation: 21

i think there is error with the
Classpath com.google.gms:google-services:4.1.0.

version I prefer to use this 4.3.13 version instead which is follow

classpath 'com.google.gms:google-services:4.3.13' my error got resolved..

it is better to use old version instead of stuck on advance version

Upvotes: 0

Jatin
Jatin

Reputation: 531

I think you need to separate these build.gradle file in two parts. First will be project level build.gradle file and second will be 'app' (module) level build.gradle.

Project Level Gradle will have :-

    apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.android.application' 
repositories {
    google()
    jcenter()
    mavenCentral()
    maven { url "https://dl.bintray.com/android/android-tools" }

}

buildscript {
    dependencies {
        classpath 'com.google.gms:google-services:4.1.0'
    }

}

And app (module) level build.gradle will have

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "sg.edu.singaporetech.teamproject"
        minSdkVersion 26
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation 'com.google.firebase:firebase-core:16.0.8'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.facebook.android:facebook-login:4.41.0'
    implementation 'com.firebaseui:firebase-ui-auth:4.3.1'
    implementation 'com.google.firebase:firebase-auth:16.2.0'
    implementation 'com.google.firebase:firebase-core:16.0.8'
    implementation 'com.google.firebase:firebase-database:16.1.0'
    implementation 'com.google.firebase:firebase-storage:16.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.jjoe64:graphview:4.2.1'
}

You may also need to add few more things in project level gradle file.

Upvotes: 0

Zaid Mirza
Zaid Mirza

Reputation: 3719

you are adding plugins more than one. please try it

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "sg.edu.singaporetech.teamproject"
        minSdkVersion 26
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation 'com.google.firebase:firebase-core:16.0.8'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.facebook.android:facebook-login:4.41.0'
    implementation 'com.firebaseui:firebase-ui-auth:4.3.1'
    implementation 'com.google.firebase:firebase-auth:16.2.0'
    implementation 'com.google.firebase:firebase-core:16.0.8'
    implementation 'com.google.firebase:firebase-database:16.1.0'
    implementation 'com.google.firebase:firebase-storage:16.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.jjoe64:graphview:4.2.1'
}

repositories {
    google()
    jcenter()
    mavenCentral()
    maven { url "https://dl.bintray.com/android/android-tools" }

}

buildscript {
    dependencies {
        classpath 'com.google.gms:google-services:4.1.0'
    }

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

UPDATED

Try to use this latest version 'com.google.gms:google-services:4.2.0'

Upvotes: 1

Related Questions