Android Studio 3.1.2 : Failed to resolve: runtime

亡梦爱人 提交于 2019-12-02 20:05:31

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()

}

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

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
}

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()
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!