Hi everyone, I have a question just to understand...
# community-support
v
Hi everyone, I have a question just to understand why it happens for me. The fix is pretty easy, but still:
Copy code
app/build.gradle.kts

val testMap = mapOf(
    "test1" to "name1",
    "test2" to "name2",
    "test3" to "name3",
)

android { 
    productFlavors.all {
        if (testMap.containsKey(name)) {
            playConfigs.register("${name}Release") {
                serviceAccountCredentials = file("$rootDir/justfolder/${testMap[name]}_manager.json")
            }
        }
    }
}
The issue that the lambda is called at some point in time when somehow
testMap
doesn't have nothing inside. So if statement works,
register
works. Do you know why does it happen that
testMap
is empty? Basically the issue that
null_manager.json
doesn't exist. My fix that works:
Copy code
android { 
    productFlavors.all {
        if (testMap.containsKey(name)) {
            val file = file("$rootDir/justfolder/${testMap[name]}_manager.json")
            playConfigs.register("${name}Release") {
                serviceAccountCredentials = file
            }
        }
    }
}
It's android but I'd assume it's the same for all
register
functions, but who knows.
v
Is this happening only when using configuration cache? And if so, are you using a Gradle version where the configuration cache is already stable? I both answers are "yes", you should probably report an issue as then I'd have expected a CC problem reported.
v
I've tried with both options:
Copy code
org.gradle.configuration-cache=true/false
same result.
v
Hm, strange, can you knit an MCVE that shows the problem?
v
I'l try 🙂
👌 1
@Vampire I have a MRE project. It's reproducible. What's next steps?
v
Provide it, for example as a GitHub project or if you don't like to create one, as archive
👍 1
v
Ah, now I see it, could have seen before. Output
name
and you will most probably see that inside you use
blaRelease
as you get the
name
from the play config while outside the
register
you get the
name
from the flavor
bla
.
💡 1
v
Thanks! Quite confusing 🙁