Search code examples
gradle-kotlin-dsl

How to apply the Google Services Plugin in a Kotlin Buildscript


How can I apply the Google Services plugin to the bottom of my app module build.gradle.kts file?

Doing it using the plugins {} block at the top of the file gives a warning and using the same block below the file causes an error since this block can't be used twice.


Solution

  • Applying the Google Services Plugin in a Kotlin build script is different from the way you would do it in Groovy.

    // Add this at the bottom of your file to actually apply the plugin
    apply(plugin = "com.google.gms.google-services")
    

    The apply function applies a plugin or a script using the given options provided as a map.