google/play-services-plugins

Migration to version catalogs is not available

karadimou-mar opened this issue ยท 9 comments

Describe the bug
When trying to migrate build to version catalogs, migration is not possible
https://developer.android.com/build/migrate-to-catalogs

Desktop (please complete the following information):

  • Gradle version: 7.3
  • Android Studio version: Hedgehog 2023.1.1
  • OSS Licenses: 0.10.4:

Hello, tell me more about this issue, whats preventing the migration?

I think I know the issue @karadimou-mar is experiencing. Plugins with version catalogs expects the plugin to be compatible with the newer plugins block

plugins {
  id("com.google.android.gms:oss-licenses") version "0.10.4"
}

But the plugin can only be resolved using the legacy plugin declaration

buildscript {
    repositories {
        google()
    }

    dependencies {
        classpath 'com.google.android.gms:oss-licenses-plugin:0.10.6'
    }
}

Works fine, even if not documented indeed.

build.gradle.kts (root):

plugins {
    ...
    alias(libs.plugins.googleServices) apply false
}

gradle/libs.versions.toml:

[versions]
googleServices = "4.4.1"

...

[plugins]
googleServices = { id = "com.google.gms.google-services", version.ref = "googleServices" }

app/build.gradle.kts (module):

plugins {
    ...
    alias(libs.plugins.googleServices)
}


android {
    ...
}

@NinoDLC

Thank you!
But I still got error below ๐Ÿค” (Looks like the artifact id is wrong.)
I use groovy. Do you think using groovy will affect this error?

* Exception is:
org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'com.google.gms.google-services', version: '4.4.1', apply: false] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'com.google.gms.google-services:com.google.gms.google-services.gradle.plugin:4.4.1')

FYI

  • Gradle version: 8.2.1
  • Android Studio version: Android Studio Iguana | 2023.2.1
  • setting.gradle
repositories {
        google()
        mavenCentral()
       ...
}

@laOLIVAesVERDE

Is repositories under the pluginManagement block?

pluginManagement {
    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}

This issue is regarding the OSS Plugin not being compatible with version catalogs. I think it's an issue with how the plugin is published. The Google services plugin releases can be found here https://maven.google.com/web/index.html#com.google.gms.google-services:com.google.gms.google-services.gradle.plugin

But there isn't an equivalent for the OSS plugin.

@jereld

I added gradlePluginPortal() and it went well. Thank you!

Is there any update for this?
project build.gradle

plugins {
id("com.google.android.gms:oss-licenses") version "0.10.4" apply false
}

Workaround like #223 (comment).