play-services-plugins icon indicating copy to clipboard operation
play-services-plugins copied to clipboard

Migration to version catalogs is not available

Open karadimou-mar opened this issue 11 months ago • 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:

karadimou-mar avatar Feb 29 '24 11:02 karadimou-mar

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

davidmotson avatar Apr 10 '24 20:04 davidmotson

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'
    }
}

jereld avatar May 01 '24 18:05 jereld

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 avatar May 15 '24 08:05 NinoDLC

@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 avatar May 15 '24 10:05 laOLIVAesVERDE

@laOLIVAesVERDE

Is repositories under the pluginManagement block?

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

jereld avatar May 15 '24 17:05 jereld

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 avatar May 15 '24 17:05 jereld

@jereld

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

laOLIVAesVERDE avatar May 16 '24 00:05 laOLIVAesVERDE

Is there any update for this? project build.gradle

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

Jaehwa-Noh avatar Jun 27 '24 06:06 Jaehwa-Noh

Workaround like https://github.com/google/play-services-plugins/issues/223#issuecomment-1236159132.

Goooler avatar Jul 11 '24 10:07 Goooler