解决后,无法更改配置':testCompile'的策略 [英] Cannot change strategy of configuration ':testCompile' after it has been resolved
问题描述
在将我的google-services版本升级到4.1.0并在构建项目期间gms:play-services-maps:16.0.0出现以下错误时.
when I upgraded my google-services version to 4.1.0 and gms:play-services-maps:16.0.0 getting below error during building the project.
A problem occurred evaluating root project ':app'.
> Failed to apply plugin [id 'com.google.gms.google-services']
> Cannot change strategy of configuration ':testCompile' after it has been resolved.
下面是我的build.gradle
Below is my build.gradle
buildscript {
repositories {
flatDir {
dirs './lib'
}
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:4.1.0'
classpath 'com.google.android.gms:strict-version-matcher-plugin:1.0.2'
}
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.android.gms.strict-version-matcher-plugin'
apply from: './jacoco.gradle'
repositories {
flatDir {
dirs './lib'
}
google()
jcenter()
}
android {
compileSdkVersion 28
buildToolsVersion 28.0.3
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
}
buildTypes {
debug {
....
}
release {
......
}
}
testOptions {
unitTests.returnDefaultValues = true
unitTests.includeAndroidResources = true
}
}
configurations {
internalDebugImplementation
}
configurations.all {
resolutionStrategy {
force "com.android.support:support-annotations:28.0.0"
}
}
dependencies {
implementation "com.android.support:support-v4:28.0.0"
implementation "com.android.support:animated-vector-drawable:28.0.0"
implementation "com.android.support:appcompat-v7:28.0.0"
implementation "com.android.support:preference-v7:28.0.0"
implementation "com.android.support:cardview-v7:28.0.0"
implementation "com.android.support:recyclerview-v7:28.0.0"
implementation "com.android.support:design:28.0.0"
implementation "com.android.support:support-annotations:28.0.0"
implementation ('com.google.android.gms:play-services-analytics:16.0.8'){
exclude group: 'com.android.support', module: 'appcompat-v7'
}
implementation ('com.google.android.gms:play-services-maps:16.0.0')
{
exclude group: 'com.android.support', module: 'appcompat-v7'
}
implementation ('com.google.android.gms:play-services-location:16.0.0'){
exclude group: 'com.android.support', module: 'appcompat-v7'
}
implementation ('com.google.android.gms:play-services-vision:16.2.0'){
exclude group: 'com.android.support', module: 'appcompat-v7'
}
implementation ('com.google.android.gms:play-services-places:16.0.0')
implementation "com.google.firebase:firebase-messaging:18.0.0"
implementation "com.google.firebase:firebase-core:16.0.9"
implementation 'com.google.maps.android:android-maps-utils:0.4'
}
task downloadDependencies(type: Exec) {
// by removing this line able to build successfully , but i dont want to remove as this is legacy code.
configurations.testCompile.files
commandLine 'echo', 'Downloaded all dependencies'
}
apply plugin: 'com.google.gms.google-services'
我尝试通过将google-services版本升级到4.2.0和gms:映射到16.1.0.没有运气.我修复了将compile sdk版本升级到28的所有依赖项问题.因此,除了仅此问题外,以上构建几乎是最终的.
I tried by upgrading google-services version to 4.2.0 and gms: maps to 16.1.0. No luck. I fixed all dependency problems with respect to upgrading compile sdk version to 28. So the above build is almost final except this issue alone.
推荐答案
将插件声明移到顶部为我解决了.尝试添加
Moving plugin declaration to the top solved for me. I got the error when I tried to add
androidExtensions {
experimental = true
}
这篇关于解决后,无法更改配置':testCompile'的策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!