在将我的google-services版本升级到4.1.0并在构建项目期间gms:play-services-maps:16.0.0出现以下错误时。
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
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。没运气。我已解决了将编译sdk版本升级到28的所有依赖问题。因此,除了仅此问题外,以上构建几乎是最终的。
答案 0 :(得分:0)
将插件声明移到顶部为我解决了。尝试添加
时出现错误androidExtensions {
experimental = true
}