1

I am trying to update google services version from 3.1.0 to 4.2.0.

root

build.gradle{
 buildscript{
  repositories {
     google()
     jcenter()
  }
  dependencies {
     classpath 'com.google.gms:google-services:4.2.0'
  }
 }
}

allprojects {
 repositories {
   jcenter()
   mavenCentral()
   google()
   flatDir {
     dirs 'libs'
   }
  }
}

I get

Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find com.google.gms:google-services:4.2.0.

Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find com.google.gms:google-services:4.2.0.
Searched in the following locations:
    https://dl.google.com/dl/android/maven2/com/google/gms/google-services/4.2.0/google-services-4.2.0.pom
    https://dl.google.com/dl/android/maven2/com/google/gms/google-services/4.2.0/google-services-4.2.0.jar
    https://jcenter.bintray.com/com/google/gms/google-services/4.2.0/google-services-4.2.0.pom
    https://jcenter.bintray.com/com/google/gms/google-services/4.2.0/google-services-4.2.0.jar

Android studio version 3.2.1

Gradle wrapper 4.6

LonsomeHell
  • 573
  • 1
  • 7
  • 29

1 Answers1

-1

I also faced this issue once.Sequence matters sometimes and remove semicolons too. try below...

build.gradle{
 buildscript{
  repositories {
     google()
     jcenter()
     mavenCentral()
  }
  dependencies {
     classpath 'com.google.gms:google-services:4.2.0'
  }
 }
}

allprojects {
 repositories {
   google()
   jcenter()
   mavenCentral()

  }
}

UPDATED : ordering resolved my issue when I faced this error. However, you need to add following repo as 4.2.0 is not available in central repo

maven { url 'https://dl.bintray.com/android/android-tools' }
Zaid Mirza
  • 3,540
  • 2
  • 24
  • 40
  • The ";" were a copy typo can you explain what items need to be ordered? – LonsomeHell Dec 10 '18 at 14:35
  • ordering sometimes creates problem. not every time. try with above sequence and see – Zaid Mirza Dec 10 '18 at 14:37
  • I got the same error still. – LonsomeHell Dec 10 '18 at 14:39
  • Order shouldn't matter, it will check every available repo listed for the class path until it is found. So order may speed up your build if you get it right, but should never cause a build to fail, just fyi. – Sam Dec 10 '18 at 14:41
  • @Sam ordering solved my problem once – Zaid Mirza Dec 10 '18 at 14:48
  • https://mvnrepository.com/artifact/com.google.gms/google-services/4.2.0 its for version 4.2.0 – Zaid Mirza Dec 10 '18 at 14:51
  • also check this answer..... https://stackoverflow.com/questions/53706565/error-could-not-find-com-google-gmsgoogle-services4-2-0 – Zaid Mirza Dec 10 '18 at 14:52
  • Hi Zaid, you are quoting other individuals. You should supply official links. Like this one https://developers.google.com/android/guides/setup where it itemizes EXACTLY what url is needed. you have found people hacking around it by by passing the built in variables. When you do this, you are in control of the URL instead of letting the native maven.google.com manage it for you. You are going straight to the source which is not a good idea as Google may change the pointer later. – Sam Dec 10 '18 at 15:02
  • @Sam look Community make it duplicated of what? dont underestimate others knowledge. – Zaid Mirza Dec 10 '18 at 20:33
  • @ZaidMirza you are welcome to continue with doing things however you would like. I am only trying to help you. The documentation does not require this url. I have 3 active Android projects ranging from Target 25 to 28. All using Google Play Services and none have this hack link in it. Whether or not you are part of a group that use a hack is not the debate here. The debate is whether or not it is necessary. You are finding a solution, rather than identifying the problem and fixing it. I am encouraging you and the asker to dig into the problem, rather than a patch. Best of luck on your methods. – Sam Dec 11 '18 at 16:24
  • if you are sure? then why you deleted your answer? lol – Zaid Mirza Dec 11 '18 at 20:40