Error: Could Not Find Com.Google.Gms:Google-Services:4.2.0

Error: could not find com.google.gms:google-services:4.2.0

Because google-services:4.2.0 is not available at Central Repository, so it needs to be downloaded from Android Tools Repository. To add this to your project add

maven { url 'https://dl.bintray.com/android/android-tools' }

this to buildscript repositories. For more refer to https://mvnrepository.com/artifact/com.google.gms/google-services/4.2.0

buildscript {
repositories {
jcenter()
google()
maven {
url 'https://maven.fabric.io/public'
}
// Add this to your project
maven { url 'https://dl.bintray.com/android/android-tools' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.2.0'

classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
// These docs use an open ended version so that our plugin
// can be updated quickly in response to Android tooling updates

// We recommend changing it to the latest version from our changelog:
// https://docs.fabric.io/android/changelog.html#fabric-gradle-plugin
classpath 'io.fabric.tools:gradle:1.27.0'
}
}

allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
}
google()
}
}

Could not find com.google.gms:google-services:4.2.3

The version 'com.google.gms:google-services:4.2.3' doesn't exist.

You can use one of these:

classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.google.gms:google-services:4.3.2'
classpath 'com.google.gms:google-services:4.3.1'
classpath 'com.google.gms:google-services:4.3.0'
classpath 'com.google.gms:google-services:4.2.0'

Can't update to com.google.gms:google-services:4.2.0

@NickUnuchek leave the dependencies block out of the gradle file of your root project, then it will work

In result top level gradle:

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

apply plugin: 'kotlin'

buildscript {
ext.kotlin_version = '1.3.20'
repositories {
google()
jcenter()
maven { url 'https://maven.fabric.io/public' }
//region realm
maven { url 'http://oss.jfrog.org/artifactory/oss-snapshot-local' }
//endregion
}
dependencies {
//region google()
classpath 'com.android.tools.build:gradle:3.3.0'
//endregion
//region jcenter()
classpath 'com.google.gms:google-services:4.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.orhanobut.tracklytics:tracklytics-plugin:2.0.0'
//endregion
//region maven { url 'https://maven.fabric.io/public' }
//to check fabric gradle ver
//https://s3.amazonaws.com/fabric-artifacts/public/io/fabric/tools/gradle/maven-metadata.xml
classpath 'io.fabric.tools:gradle:1.+'
//endregion
//region realm
classpath "io.realm:realm-gradle-plugin:5.8.0"
//endregion
}
}

allprojects {
repositories {
mavenLocal()
google()
jcenter()
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
maven { url "https://dl.bintray.com/nickunuchek/maven" }
maven { url "https://jitpack.io" }
}

configurations.all {
exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib-jre7'
}
}

dependencies {
//REMOVED FROM TOP-LEVEL implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}

compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}

app/build.gradle:

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'

android {
...

defaultConfig {
...
versionCode 1
versionName "1.0"
multiDexEnabled true
}

dexOptions {
javaMaxHeapSize "8g"
preDexLibraries = false
}

compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}

}

dependencies {
...
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"//MOVED HERE FROM TOP-LEVEL GRADLE
}

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

ERROR: Could not find com.google.gms.google-services:4.2.0

You have a typo in the classpath statement.

This

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

should be

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

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

I think you need to separate these build.grdle file in two parts. First will project level build.gradle 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.

Where do i add the com.google.gms:google-services plugin in my android project?

It is new format you can add in your plugins like this

id 'com.google.gms.google-services' version '4.3.10' apply false

Cannot resolve external dependency com.google.gms:google-services:4.2.0 because no repositories are defined. Android Studio 3.5

try adding following in "app" level gradle file

repositories {
mavenCentral()
}


Related Topics



Leave a reply



Submit