Search code examples
androidgradle-kotlin-dslandroid-gradle-plugin-3.3.0heap.io

How can I define an ext property from Heap.io with gradle kotlin dsl


Im using the heap.io and their Android SDK and they advise you to setup their library like:

  • build.gradle:
android {
    defaultConfig {
        // Add this section to enable Heap event capture.
        ext {
          heapEnabled = true
        }
        // ...
    }
    // ...
}

But this is using the gradle groovy sintax, Im trying to use it with the Kotlin DSL of gradle like:

  • build.gradle.kts
android {
    defaultConfig {
        ext {
            set("heapEnabled", true)
        }

But it does not work for some reason, so:

Why that may be happening?


Solution

  • I was able to make it work using withGroovyBuilder like:

    android {
        defaultConfig {
            withGroovyBuilder {
                "ext" {
                    setProperty("heapEnabled", LhConfig.isAnalyticEnabled(project))
                }
            }
    

    I still dont understand where is the issue :(