40

I have recently updated my Android Studio to 3.1.2 . After the update I tried opening the existing project and was shown multiple gradle errors while compiling the project.

Those errors pointed me to update the 'compile' statement to 'implementation', which I did, still faced some errors which I later solved by updating my google play and firebase sdks to latest version.

Now I have no clue why is my IDE giving the following error (look at the screenshot).

Failed to resolve: runtime

enter image description here).

Now when I did Build > Clean Project

The error was Could not find runtime.aar (android.arch.lifecycle:runtime:1.0.3). Screen shot enter image description here

What to do next?

SOLUTION:

  1. I updated all my google play services and firebase libs.
  2. To solve could not find runtime aar, I just simply arranged the google() on top in repositories.
Udit Kapahi
  • 2,277
  • 1
  • 27
  • 25

4 Answers4

64

yes ,

If you are getting error like error run time you can change the position of google() in dependencies in build. gradle.. Like below:

repositories {
    google()
    jcenter()

}
user9913591
  • 649
  • 4
  • 2
  • 1
    This worked for me after I changed the order in `allprojects { repositories {`, not `buildscript { repositories {` which I changed first. – Cameron Taggart Jun 11 '18 at 00:29
  • 1
    This also worked for me. It was working on `Android Studio 3.0.1`, but not on `Android Studio 3.1.2` I had to add `google()` as first in the `allprojects { repositories { google() ... } }` – SnuKies Jun 11 '18 at 08:27
  • 2
    Worked for me.. but can someone please explain why does it even work. They can create this awesome Android Studio, but these type of silly things they can not tackle with? – androCoder-BD Jun 15 '18 at 21:28
  • this is what its really like to be an android developer. having to figure these things out. what a waste of time – Lou Morda Oct 24 '18 at 23:31
6

android.arch.lifecycle:runtime is available at the google maven repository. Make sure you add the repository in the repositories block of your build.gradle

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

or

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

Reference : Adding Components to your Project

Alim Parkar
  • 632
  • 3
  • 9
5

Please follow this as same (sequentially) in build.gradle (project: projectName) and issue will be gone

buildscript {

repositories { // keep same this order
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.1.3'

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

allprojects { // keep same this order
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
delete rootProject.buildDir
}
Ramkesh Yadav
  • 987
  • 2
  • 11
  • 16
5

Add maven { url 'https://maven.google.com' } as first entry in allprojects/repositories in top level build.gradle

like this:

allprojects {
    repositories {
        maven { url 'https://maven.google.com' }
        google()
        maven { url "https://jitpack.io" }
        jcenter()
    }
}
Saeed
  • 3,294
  • 5
  • 35
  • 52