https://kotlinlang.org logo
Title
m

Malvin Sutanto

10/31/2019, 7:43 AM
Trying to convert my build.gradle to kts but having issue with productFlavor’s
isDefault
flag. I tried
isDefault.set(true)
but getting
Unresolved reference
error.
isDefault
itself is marked as private in
BuildType
class. Has anybody encountered the same issue before?
The
productFlavors
block looks like this:
productFlavors {
        create("qa") {
            dimension = "environment"
            isDefault.set(true)
            applicationIdSuffix = ".$name"
        }
            ...
    }
m

mbonnin

10/31/2019, 9:36 AM
Maybe there's a setter somewhere like
setDefault()
?
m

Malvin Sutanto

10/31/2019, 9:39 AM
There’s another method
setIsDefault
but invoking that method also throws
Unresolved reference
error
Also tried looking at all available methods by using
this::class.java.methods
and I can see both
getIsDefault
and
setIsDefault
present
m

mbonnin

10/31/2019, 1:55 PM
You should be able to do
getIsDefault().set(true)
Somehow groovy understands
Property
and can set it without you having to call
.set
m

Malvin Sutanto

11/01/2019, 1:37 AM
Tried
getIsDefault().set(true)
as well, but still getting
UnresolvedReference
error. I printed out the class name, and it showed me
ProductFlavor_Decorated
🤔
g

gildor

11/01/2019, 1:46 AM
showed me
ProductFlavor_Decorated
It’s fine, this is how Gradle extension work
m

Malvin Sutanto

11/01/2019, 1:49 AM
I see, this class is generated during runtime? Is there any way to see the implementation of this class?
g

gildor

11/01/2019, 1:50 AM
Yes, during configuration time
Which version of Android Gradle Plugin do you use?
m

Malvin Sutanto

11/01/2019, 1:52 AM
3.6.0 beta 1
I can see
getIsDefault
declared in
ProductFlavor
class and AS can refer to the method correctly, but it throws
Unresolved Reference
error when I try to do a gradle sync
g

gildor

11/01/2019, 1:58 AM
what about build from console?
m

Malvin Sutanto

11/01/2019, 2:01 AM
Tried
gradlew build
but same
^ Unresolved reference
error
Accessing it through reflection
this::class.java.getMethod("getIsDefault")
tells me that the method does exist
g

gildor

11/01/2019, 2:33 AM
Works for me on 3.6.0-beta02
just checked
are you sure that you are on the right version of AGP?
Maybe somethong overrides your config
m

Malvin Sutanto

11/01/2019, 2:45 AM
Hmm, yeah, perhaps one of the gradle plugin overrides dependency for AGP
Let me take a look further, thanks!
g

gildor

11/01/2019, 2:47 AM
Print to console
println(com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION)
m

Malvin Sutanto

11/01/2019, 2:54 AM
3.6.0-beta01
g

gildor

11/01/2019, 2:57 AM
Maybe some issue of beta01, try beta02
m

Malvin Sutanto

11/01/2019, 3:13 AM
Will do! 👍
Same issue in beta02, so I guess the issue is in my dependencies