我收到以下错误:
Cannot change dependencies of configuration ':app:api' after it has been included in dependency resolution.
更新
禁用数据绑定时,我可以使用com.google.gms:google-services:3.3.0
进行构建,但对于需要启用数据绑定的人来说,这不是一个解决方案。
Google宣布推出新的sdk版本控制系统(link)后,我执行了以下步骤:
我按指示更新了gradle文件,分别包含gms和firebase版本号。更新了apply插件行,更新了类路径。我仍然得到错误,不知道原因。
以下是相关的gradle文件:
build.gradle(main):
buildscript {
repositories {
google()
jcenter()
maven { url 'https://dl.bintray.com/rvalerio/maven' }
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:3.3.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'io.realm:realm-gradle-plugin:4.3.3'
classpath 'io.fabric.tools:gradle:1.25.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://jitpack.io' }
maven { url 'https://maven.google.com' }
}
}
build.gradle(Module:app)
apply plugin: 'com.google.gms.google-services'
Firebase依赖项:
//Firebase Dependencies
implementation "com.google.firebase:firebase-messaging:15.0.2"
implementation "com.google.firebase:firebase-core:15.0.2"
implementation "com.google.firebase:firebase-config:15.0.2"
implementation('com.crashlytics.sdk.android:crashlytics:2.9.1@aar') {
transitive = true
}
GMS和其他依赖项
implementation "com.android.support:recyclerview-v7:27.1.1"
implementation "com.android.support:support-v4:27.1.1"
implementation "com.android.support:cardview-v7:27.1.1"
implementation "com.android.support:design:27.1.1"
implementation "com.android.support:support-v13:27.1.1"
implementation "com.android.support.constraint:constraint-layout:1.1.0"
implementation "com.google.android.gms:play-services-location:15.0.1"
implementation "com.google.android.gms:play-services-vision:15.0.1"
implementation "com.google.android.gms:play-services-auth:15.0.1"
implementation "com.google.android.gms:play-services-maps:15.0.1"
感谢任何帮助!
答案 0 :(得分:15)
成功打造Play Services& Firebase 15.0.0
已启用数据绑定 ...我的依赖项现在看起来与此类似,并且它再次构建,没有任何Cannot change dependencies of configuration
投诉:
buildscript {
dependencies {
classpath "com.android.tools.build:gradle:3.1.2"
// do not update, because 3.3.1 appears broken
// classpath "com.google.gms:google-services:3.2.1"
// meanwhile, there is version 4.0.2 available
classpath "com.google.gms:google-services:4.0.2"
}
}
必须单独引用所有库。由于com.google.android.gms:play‐services
,仅引用com.google.firebase:firebase-core
和/或15.0.0
不再有效。
android {
dependencies {
// Play Services 15.0.0
implementation "com.google.android.gms:play-services-base:15.0.1"
implementation "com.google.android.gms:play-services-auth:15.0.1"
implementation "com.google.android.gms:play-services-identity:15.0.1"
// Firebase 15.0.0
implementation "com.google.firebase:firebase-core:15.0.2"
implementation "com.google.firebase:firebase-database:15.0.1"
implementation "com.google.firebase:firebase-firestore:16.0.0"
implementation "com.google.firebase:firebase-storage:15.0.2"
implementation "com.google.firebase:firebase-crash:15.0.2"
implementation "com.google.firebase:firebase-auth:15.1.0"
implementation "com.google.firebase:firebase-messaging:15.0.2"
implementation "com.google.firebase:firebase-config:15.0.2"
implementation "com.google.firebase:firebase-invites:15.0.1"
implementation "com.google.firebase:firebase-ads:15.0.1"
implementation "com.google.firebase:firebase-appindexing:15.0.1"
implementation "com.google.firebase:firebase-perf:15.2.0"
implementation "com.google.firebase:firebase-functions:15.0.0"
}
}
apply plugin: 'com.google.gms.google-services'
还必须编辑Manifest.xml
来修复支持库:
<application>
<meta-data
android:name="android.support.VERSION"
android:value="27.1.1"
tools:replace="android:value"/>
</application
答案 1 :(得分:5)
此处报告了数据绑定和3.3.0
插件google-services
版本的问题:https://issuetracker.google.com/issues/79122163
截至今天,该错误处于“已分配”状态。
答案 2 :(得分:2)
<强>更新强> 我也可以用
编译dataBinding.enabled false
在android配置和版本3.3.0中
<强> ORIGINAL 强>
与google-services相同的问题:3.3.0,这是最后一个版本,但根据docs版本3.2.1应该使用。我已经能够使用以下
进行编译 ext {
kotlin_version = '1.2.41'
firebaseCore = '15.0.2'
authentication = '15.1.0'
cloudFirestore = '16.0.0'
cloudStorage = '15.0.2'
crashlitics = '2.9.1'
googleServices = '15.0.0'
supportLibrary = '27.1.1'
facebookSdkVersion = '4.31.0'
twitterSdkVersion = '3.1.1'
firebaseUI = '3.3.1'
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0-alpha12'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:3.2.1'
}
答案 3 :(得分:2)
此问题似乎已通过使用新的google-services版本(截至今天的4.0.1)得到解决。以下是将解决所述问题的相关版本:
在项目build.gradle文件中:
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:4.0.1' }
在你的app build.gradle文件中:
//Firebase Dependencies
implementation "com.google.firebase:firebase-messaging:17.0.0"
implementation "com.google.firebase:firebase-core:16.0.0"
implementation "com.google.firebase:firebase-config:16.0.0"
implementation 'com.google.firebase:firebase-perf:16.0.0'
...} apply plugin: "com.google.gms.google-services"
Databinding也设置为true:
dataBinding {
enabled = true
}
Android Studio版本:3.1.2
感谢大家提供各种解决问题的方法,例如@Kyle的回答以及介绍如何在没有谷歌服务的情况下使用firebase的中等帖子链接。
答案 4 :(得分:1)
只需将您的Google Play服务依赖关系降级为3.2.1:)
classpath 'com.google.gms:google-services:3.2.1'
答案 5 :(得分:0)
虽然不是一个很好的解决方案,但我遵循了bug追踪器上提到的Google员工的建议。
我正在使用
com.google.gms:google-services:3.3.1
我启用了数据绑定
`dataBinding.enabled true`
我从app gradle脚本中删除了插件引用
//apply plugin: 'com.google.gms.google-services'
并按照此媒体帖子中的建议添加所有必要的Google服务字符串值。
我的应用已成功构建,一切正常。
答案 6 :(得分:0)
在我的项目build.gradle中的allProjects块中添加google()maven后,一切正常工作:
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
...
}
}
repositories {
...
}
// You need to add the google maven in this block.
allprojects {
repositories {
jcenter()
google()
}
}