Cannot change strategy of configuration ':testCompile' after it has been resolved
Asked Answered
A

1

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.

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'

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.

Academia answered 16/5, 2019 at 6:12 Comment(5)
use classpath 'com.android.tools.build:gradle:3.2.1'Appearance
if you remove this then ? 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' }Appearance
@IntelliJAmiya I tried with 3.2.1. Got some other issues w.r.t compilation. Will try again. And this downloadDependencies() used for jenkin stuffs. So i dont want to remove those.Academia
github.com/OneSignal/OneSignal-Gradle-Plugin/issues/…Appearance
Tried with build:gradle:3.2.1. Same error. Will try by adding androidExtensionsAcademia
R
0

Moving plugin declaration to the top solved for me. I got the error when I tried to add

androidExtensions {
    experimental = true
}
Riccardo answered 16/5, 2019 at 6:32 Comment(3)
github.com/OneSignal/OneSignal-Gradle-Plugin/issues/…Appearance
I tried adding androidExtension{experimental=true} in all the places like after apply plugin, inside android {....} etc.. Its giving me "Could not find method androidExtensions() for arguments" error. Any plugin we need to add to use this property ? I think this will work when we are using "'kotlin-android-extensions'" plugin.Academia
I'm trying to find options without adding kotlin stuffs.Academia

© 2022 - 2024 — McMap. All rights reserved.