OSS Licences Plugin fails with Gradle 8.8
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
+1. also with Android Studio Jellyfish
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
Consider migrating to https://github.com/cashapp/licensee.
Thanks for the tip @Goooler I had a quick look but licensee does not look like a replacement. IT seems to do something different.
You can use the generated JSON file and parse info to show license page like https://github.com/chrisbanes/tivi/issues/1471.
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.
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 that project might not use productFlavors — I didn't notice any on a cursory glance at their build.gradle files
I am stuck with the same problem any one found the fix ?
You can consider migrating to a third-party library https://github.com/mikepenz/AboutLibraries which is well maintained and provides the same functionality
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
Task :app:freeReleaseOssLicensesTask of type com.google.android.gms.oss.licenses.plugin.LicensesTask: invocation of 'Task.project' at execution time is unsupported.
There is an easy way to bundle the
artifacts.jsonfor you, see https://github.com/cashapp/licensee/releases/tag/1.13.0.
Originally posted by @Goooler in #206
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