数据绑定和 Google 服务插件无法协同工作
Data Binding andGoogle Services plugin not work together
我在我的项目中使用 firebase。所以在我的 app/build.gradle 文件的底部是
apply plugin: 'com.google.gms.google-services'
.
当我想用
激活数据绑定时
dataBinding {enabled true}
我遇到了错误;
"Gradle sync failed: Can not change dependencies of configuration ': app: api' after it has been included in dependency resolution."
因此,添加多个插件时,DataBinding报错。我仍然找不到解决方案。
如何在使用 Google 服务的项目中使用数据绑定?
Android Studio 3.1.2
Gradle4.4
问题出在gms版本。该问题已在 4.0.1
版本中得到解决
// classpath 'com.google.gms:google-services:3.3.1'
classpath 'com.google.gms:google-services:4.0.1'
通过进一步的步骤修复 -
1 在应用级别 bulid.gradel 文件中。
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "test.com.apptest"
minSdkVersion 15
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'
}
}
dataBinding {
enabled = true
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
// add firbase
implementation 'com.google.firebase:firebase-messaging:15.0.2'
}
2。项目级 gradel 文件。
构建脚本{
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:3.2.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
我在我的项目中使用 firebase。所以在我的 app/build.gradle 文件的底部是
apply plugin: 'com.google.gms.google-services'
.
当我想用
激活数据绑定时dataBinding {enabled true}
我遇到了错误;
"Gradle sync failed: Can not change dependencies of configuration ': app: api' after it has been included in dependency resolution."
因此,添加多个插件时,DataBinding报错。我仍然找不到解决方案。 如何在使用 Google 服务的项目中使用数据绑定?
Android Studio 3.1.2 Gradle4.4
问题出在gms版本。该问题已在 4.0.1
版本中得到解决// classpath 'com.google.gms:google-services:3.3.1'
classpath 'com.google.gms:google-services:4.0.1'
通过进一步的步骤修复 -
1 在应用级别 bulid.gradel 文件中。
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "test.com.apptest"
minSdkVersion 15
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'
}
}
dataBinding {
enabled = true
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
// add firbase
implementation 'com.google.firebase:firebase-messaging:15.0.2'
}
2。项目级 gradel 文件。
构建脚本{
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:3.2.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}