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

OSS Licences Plugin fails with Gradle 8.8

Open jakob-grabner opened this issue 1 year ago • 14 comments

Describe the bug After updating to Gradle 8.8 the OssLicensesTask fails to resolve module variants.

Execution failed for task ':running:googleDevelopmentReleaseOssLicensesTask'.

The consumer was configured to find a library for use during runtime, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '8.4.2', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release', attribute 'com.android.build.api.attributes.ProductFlavor:environment' with value 'development', attribute 'com.android.build.api.attributes.ProductFlavor:market' with value 'google', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm'. However we cannot choose between the following variants of project :partner-accounts:partner-accounts: - Configuration ':partner-accounts:partner-accounts:releaseRuntimeElements' variant android-aar-metadata declares a library for use during runtime, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '8.4.2', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm': - Unmatched attributes: - Doesn't say anything about com.android.build.api.attributes.ProductFlavor:environment (required 'development') - Doesn't say anything about com.android.build.api.attributes.ProductFlavor:market (required 'google') - Provides attribute 'artifactType' with value 'android-aar-metadata' but the consumer didn't ask for it - Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'release' but the consumer didn't ask for it

To Reproduce Steps to reproduce the behavior: Update Gradle to 8.8

Desktop (please complete the following information):

  • Gradle version: 8.8
  • Android Studio version: Android Studio Koala
  • Plugin name and version: com.google.android.gms.oss-licenses-plugin" version "0.10.6"

Additional context Everything works if I downgrade to gradle 8.7

jakob-grabner avatar Jun 20 '24 06:06 jakob-grabner

+1. also with Android Studio Jellyfish

Blackzion avatar Jun 21 '24 11:06 Blackzion

This is a blocker for us as well, it fails on release variant of a module. We cannot downgrade the Gradle version at the moment. Please let us know if there is a plan on fixing this? Thanks

ArcherEmiya05 avatar Jul 03 '24 14:07 ArcherEmiya05

Consider migrating to https://github.com/cashapp/licensee.

Goooler avatar Jul 11 '24 10:07 Goooler

Thanks for the tip @Goooler I had a quick look but licensee does not look like a replacement. IT seems to do something different.

jakob-grabner avatar Jul 11 '24 11:07 jakob-grabner

You can use the generated JSON file and parse info to show license page like https://github.com/chrisbanes/tivi/issues/1471.

Goooler avatar Jul 11 '24 12:07 Goooler

This unfortunately means that this plugin is now incompatible with the latest stable android gradle plugin (8.7) which requires a minimum gradle version of 8.9.

mateot1 avatar Oct 09 '24 17:10 mateot1

This unfortunately means that this plugin is now incompatible with the latest stable android gradle plugin (8.7) which requires a minimum gradle version of 8.9.

To my amazement it seems to work with the new versions in the Now in Android app. At least I could compile the project with the release build type. It still does not work for my project though (because of this issue)

alixwar avatar Oct 09 '24 18:10 alixwar

@alixwar that project might not use productFlavors — I didn't notice any on a cursory glance at their build.gradle files

mateot1 avatar Oct 09 '24 21:10 mateot1

I am stuck with the same problem any one found the fix ?

kumar5e avatar Jan 15 '25 13:01 kumar5e

You can consider migrating to a third-party library https://github.com/mikepenz/AboutLibraries which is well maintained and provides the same functionality

MattSkala avatar Jan 15 '25 13:01 MattSkala

I am stuck with the same problem any one found the fix ?

I moved on to use a 3rd party library, https://github.com/cashapp/licensee

This librarys primary purpose is to validate licenses, so not exactly a clean migration from Google OSS Licenses plugin. But you can add JSON parsing and a custom UI as was done for the Tivi app: https://github.com/chrisbanes/tivi/pull/1528/files

alixwar avatar Jan 15 '25 14:01 alixwar

Task :app:freeReleaseOssLicensesTask of type com.google.android.gms.oss.licenses.plugin.LicensesTask: invocation of 'Task.project' at execution time is unsupported.

devsigofficial avatar Apr 12 '25 18:04 devsigofficial

There is an easy way to bundle the artifacts.json for you, see https://github.com/cashapp/licensee/releases/tag/1.13.0.

Originally posted by @Goooler in #206

Goooler avatar Apr 13 '25 02:04 Goooler

Starting with Gradle 8.8, Gradle throws ArtifactSelectionException instead of AmbiguousVariantSelectionException. The OSS plugin is expected to handle this exception for client app but fail

The following code should resolve this issue https://github.com/google/play-services-plugins/pull/305

mse-JoNa avatar Aug 20 '25 09:08 mse-JoNa