无法解决:添加谷歌架构组件依赖项时支持片段错误

hos*_*ini 9 android android-gradle-plugin android-architecture-components

我想在我的应用程序中使用Google架构组件,但在将android Studio更新为3.1.1时,我将android.arch.lifecycle:extensions:1.1.1依赖项添加到app.gradle文件中,它将显示Failed to resolve: support-fragment
我的gradle版本为4.4

在此输入图像描述

这是app gardle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "ir.apptori.myapplication"
        minSdkVersion 17
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner 
 "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'

    implementation "android.arch.lifecycle:extensions:1.1.1"
}
Run Code Online (Sandbox Code Playgroud)

请指导我如何解决它,谢谢

xil*_*lef 62

我有一个类似的错误,并改变repositories顺序,以便google()jcenter()修复之前.

我不得不更改repositories内部buildscript allprojects顶级build.gradle文件的顺序.

请参阅此提交:https: //github.com/kunadawa/ud851-Exercises/commit/9f6720ef4d52c71b206ddaa8477f2cf6e77a66f4

  • 这个问题解决了我的问题...整天都在为此搜索解决方案而浪费了...非常感谢你应该接受这个答案 (2认同)