无法解析':app @ debug / compileClasspath'的依赖项:无法解析com.android.databinding:library:3.2.1

时间:2018-10-31 05:55:46

标签: android android-studio android-databinding

我遇到了Android Studio 3.2.1的问题,并且Gradle构建版本是4.6。最近,我将我的android studio更新为3.2.1,并且gradle也更新为4.6。如果我们删除dataBinding,错误将消失。添加dataBinding之后,它的给定问题就像

router.route('/')
    .post(asyncHandler(insert));

有人解决了这个问题,在这种情况下请帮忙。我已经尝试了所有试验,但没有成功。

  Unable to resolve dependency for ':app@debug/compileClasspath': Could 
  not resolve com.android.databinding:library:3.2.1.

  Unable to resolve dependency for ':app@debug/compileClasspath': Could 
  not resolve com.android.databinding:adapters:3.2.1.

  Unable to resolve dependency for 
  ':app@debugAndroidTest/compileClasspath': Could not resolve 
   com.android.databinding:library:3.2.1.

  my Gradle build of the project level is
      buildscript {

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

}
dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'


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

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

    task clean(type: Delete) {
        delete rootProject.buildDir
     }

3 个答案:

答案 0 :(得分:0)

我在您的gradle中进行了一些编辑。

项目级别

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
    }
}

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

task clean(type: Delete) {
    delete rootProject.buildDir
}

应用级别

apply plugin: 'com.android.application'
android {
    compileSdkVersion 27
    buildToolsVersion '28.0.3'
    defaultConfig {
        applicationId "com.sample.mvvmandroidstudio"
        minSdkVersion 21
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dataBinding {
        enabled = true
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
}

我所做的更改:

  • 已删除重复的Google存储库
  • 删除了测试依赖项,因为我不认为您会使用它。

答案 1 :(得分:0)

我通过将android studio更新到最新版本解决了问题。

感谢Khemraj宝贵的时间。

答案 2 :(得分:0)

可以通过在设置->构建,执行部署->渐变中取消选中离线工作来解决此问题。希望对您有所帮助。