Trying to convert my build.gradle to kts but havin...
# gradle
m
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:
Copy code
productFlavors {
        create("qa") {
            dimension = "environment"
            isDefault.set(true)
            applicationIdSuffix = ".$name"
        }
            ...
    }
m
Maybe there's a setter somewhere like
setDefault()
?
m
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
You should be able to do
getIsDefault().set(true)
Somehow groovy understands
Property
and can set it without you having to call
.set
m
Tried
getIsDefault().set(true)
as well, but still getting
UnresolvedReference
error. I printed out the class name, and it showed me
ProductFlavor_Decorated
🤔
g
showed me
ProductFlavor_Decorated
It’s fine, this is how Gradle extension work
m
I see, this class is generated during runtime? Is there any way to see the implementation of this class?
g
Yes, during configuration time
Which version of Android Gradle Plugin do you use?
m
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
what about build from console?
m
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
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
Hmm, yeah, perhaps one of the gradle plugin overrides dependency for AGP
Let me take a look further, thanks!
g
Print to console
println(com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION)
m
3.6.0-beta01
g
Maybe some issue of beta01, try beta02
m
Will do! 👍
Same issue in beta02, so I guess the issue is in my dependencies