使用android dataBinding时出错

时间:2018-07-05 16:55:09

标签: android data-binding build.gradle

当我在app / build.gradle中启用dataBinding时出现一个问题,该错误提示我:“错误:无法解决:support-v4”。下面是带有依赖项和库的构建文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    dataBinding {
        enabled = true
    }
    defaultConfig {
        applicationId "com.dxhf.studio.databinding"
        minSdkVersion 16
        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(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.0.2'
    testImplementation 'junit:junit:4.12'
    implementation 'com.android.support:design:27.0.2'
}

我添加了support-v4,但是它没有解决问题,并且在删除dataBinding部分时也没有问题。是什么原因引起的问题?

更新1。 这是我的项目级别的Gradle文件。

buildscript {

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

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

allprojects {
   repositories {
      google()
      jcenter()

  }
}

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

0 个答案:

没有答案