android - 使用android dataBinding时出错
问题描述
当我在 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
}
解决方案
推荐阅读
- angular - 错误:在 Angular 中使用路由器出口名称时无法匹配任何路由
- java - 尝试利用从 PDF 中捕获的文本
- ios - 将 char 数组转换为 NSString 对象的方式,最后一个字符
- node.js - 使用 express 的 http 响应中的自定义值(不在正文中)
- excel - 如何用 Condition 组合 Offset 函数?
- bash - 如何使用没有循环的bash从数组中获取单个值
- c# - ASP.NET Core API 的 ProducesResponseType 属性中包含的正确类型是什么?
- javascript - 如何链接 JavaScript 文件?
- python - 如何在“map”函数调用中将参数传递给函数?
- javascript - 如何选择父节点的第一个子节点?