Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execution failed for task ':automotive:cyclonedxBom' #259

Closed
chetan-ansel opened this issue Jan 9, 2023 · 4 comments
Closed

Execution failed for task ':automotive:cyclonedxBom' #259

chetan-ansel opened this issue Jan 9, 2023 · 4 comments
Labels
android Android related issues

Comments

@chetan-ansel
Copy link

I have tried cyclonedxBom in an android project with the Gradle version
classpath 'com.android.tools.build:gradle:7.0.2'
and kotlin version
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20"

cycloneDxBom: plugins {
id 'org.cyclonedx.bom' version '1.7.3'
}
apply plugin: 'org.cyclonedx.bom'

and every time Build failed with an exception.

Execution failed for task ':automotive:cyclonedxBom'.

The consumer was configured to find a runtime of a component, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm'. However we cannot choose between the following variants of project :automotive:
- Configuration ':automotive:releaseRuntimeElements' variant android-base-module-lint-variant-dependencies-model declares a runtime of a component, preferably optimized for Android
, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Provides attribute 'artifactType' with value 'android-base-module-lint-variant-dependencies-model' 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
- Provides a library but the consumer didn't ask for it
- Configuration ':automotive:releaseRuntimeElements' variant android-java-res declares a runtime of a component, preferably optimized for Android, as well as attribute 'com.android
.build.api.attributes.BuildTypeAttr' with value 'release', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Provides attribute 'artifactType' with value 'android-java-res' 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
- Provides a library but the consumer didn't ask for it
- Configuration ':automotive:releaseRuntimeElements' variant android-lint-variant-dependencies-model declares a runtime of a component, preferably optimized for Android, as well as
attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Provides attribute 'artifactType' with value 'android-lint-variant-dependencies-model' 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
- Provides a library but the consumer didn't ask for it
- Configuration ':automotive:releaseRuntimeElements' variant android-navigation-json declares a runtime of a component, preferably optimized for Android, as well as attribute 'com.
android.build.api.attributes.BuildTypeAttr' with value 'release', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Provides attribute 'artifactType' with value 'android-navigation-json' 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
- Provides a library but the consumer didn't ask for it
- Configuration ':automotive:releaseRuntimeElements' variant android-packaged-dependencies declares a runtime of a component, preferably optimized for Android, as well as attribute
'com.android.build.api.attributes.BuildTypeAttr' with value 'release', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Provides attribute 'artifactType' with value 'android-packaged-dependencies' 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
- Provides a library but the consumer didn't ask for it
- Configuration ':automotive:releaseRuntimeElements' variant apk declares a runtime of a component, preferably optimized for Android, as well as attribute 'com.android.build.api.at
tributes.BuildTypeAttr' with value 'release', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Provides attribute 'artifactType' with value 'apk' 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
- Provides a library but the consumer didn't ask for it
- Configuration ':automotive:releaseRuntimeElements' variant bundle-apks declares a runtime of a component, preferably optimized for Android, as well as attribute 'com.android.buil
d.api.attributes.BuildTypeAttr' with value 'release', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Provides attribute 'artifactType' with value 'bundle-apks' 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
- Provides a library but the consumer didn't ask for it

Note: When I lowered the version of Gradle to 3.6.4( classpath 'com.android.tools.build:gradle:3.6.4') and build executed successfully and cycloneDx was able to generate reports files(bom.json and bom.xml)

@chetan-ansel
Copy link
Author

It got works when I added configuration:
cyclonedxBom {
skipConfigs = [
"debugCompileClasspath",
"debugAndroidTestCompileClasspath",
"debugUnitTestCompileClasspath",
"releaseUnitTestCompileClasspath",
"debugUnitTestRuntimeClasspath",
"releaseUnitTestRuntimeClasspath"
]
}

**But when I tried on another project with flavor it got failed(
productFlavors {
nonprod {
dimension AppLevelDependencies.AppConfig.appDimension
applicationId AppLevelDependencies.AppConfig.qaApplicationId
}
prod {
dimension AppLevelDependencies.AppConfig.appDimension
applicationId AppLevelDependencies.AppConfig.prodApplicationId

    }
}

**sourceSets** {
    prod {
        res { 'src/prod/res' }
    }
    nonprod {
        res { 'src/nonprod/res' }
    }
}. ]Below is the error:**  

The consumer was configured to find a runtime of a component, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'com.android.build.api.attributes.ProductFlavor:environment' with value 'prod', attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.1.0', attribute
'org.jetbrains.kotlin.platform.type' with value 'androidJvm'. However we cannot choose between the following variants of project :automotive:
- Configuration ':automotive:prodDebugRuntimeElements' variant android-base-module-lint-variant-dependencies-model declares a runtime of a component, preferably optimized for Andro
id, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.1.0', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute
'com.android.build.api.attributes.ProductFlavor:environment' with value 'prod', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Provides attribute 'artifactType' with value 'android-base-module-lint-variant-dependencies-model' but the consumer didn't ask for it
- Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'prodDebug' but the consumer didn't ask for it
- Provides attribute 'environment' with value 'prod' but the consumer didn't ask for it
- Provides a library but the consumer didn't ask for it
- Configuration ':automotive:prodDebugRuntimeElements' variant android-java-res declares a runtime of a component, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.1.0', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'com.android.build.api.attributes.P
roductFlavor:environment' with value 'prod', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Provides attribute 'artifactType' with value 'android-java-res' but the consumer didn't ask for it
- Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'prodDebug' but the consumer didn't ask for it
- Provides attribute 'environment' with value 'prod' but the consumer didn't ask for it
- Provides a library but the consumer didn't ask for it
- Configuration ':automotive:prodDebugRuntimeElements' variant android-lint-variant-dependencies-model declares a runtime of a component, preferably optimized for Android, as well
as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.1.0', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'com.android
.build.api.attributes.ProductFlavor:environment' with value 'prod', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Provides attribute 'artifactType' with value 'android-lint-variant-dependencies-model' but the consumer didn't ask for it
- Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'prodDebug' but the consumer didn't ask for it
- Provides attribute 'environment' with value 'prod' but the consumer didn't ask for it
- Provides a library but the consumer didn't ask for it
- Configuration ':automotive:prodDebugRuntimeElements' variant android-navigation-json declares a runtime of a component, preferably optimized for Android, as well as attribute 'co
m.android.build.api.attributes.AgpVersionAttr' with value '7.1.0', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'com.android.build.api.attri
butes.ProductFlavor:environment' with value 'prod', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Provides attribute 'artifactType' with value 'android-navigation-json' but the consumer didn't ask for it
- Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'prodDebug' but the consumer didn't ask for it
- Provides attribute 'environment' with value 'prod' but the consumer didn't ask for it
- Provides a library but the consumer didn't ask for it
- Configuration ':automotive:prodDebugRuntimeElements' variant android-packaged-dependencies declares a runtime of a component, preferably optimized for Android, as well as attribu
te 'com.android.build.api.attributes.AgpVersionAttr' with value '7.1.0', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'com.android.build.api
.attributes.ProductFlavor:environment' with value 'prod', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Provides attribute 'artifactType' with value 'android-packaged-dependencies' but the consumer didn't ask for it
- Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'prodDebug' but the consumer didn't ask for it
- Provides attribute 'environment' with value 'prod' but the consumer didn't ask for it
- Provides a library but the consumer didn't ask for it
- Configuration ':automotive:prodDebugRuntimeElements' variant apk declares a runtime of a component, preferably optimized for Android, as well as attribute 'com.android.build.api.
attributes.AgpVersionAttr' with value '7.1.0', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'com.android.build.api.attributes.ProductFlavor:
environment' with value 'prod', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Provides attribute 'artifactType' with value 'apk' but the consumer didn't ask for it
- Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'prodDebug' but the consumer didn't ask for it
- Provides attribute 'environment' with value 'prod' but the consumer didn't ask for it
- Provides a library but the consumer didn't ask for it
- Configuration ':automotive:prodDebugRuntimeElements' variant bundle-apks declares a runtime of a component, preferably optimized for Android, as well as attribute 'com.android.bu
ild.api.attributes.AgpVersionAttr' with value '7.1.0', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'com.android.build.api.attributes.Produc
tFlavor:environment' with value 'prod', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
- Unmatched attributes:
- Provides attribute 'artifactType' with value 'bundle-apks' but the consumer didn't ask for it
- Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'prodDebug' but the consumer didn't ask for it
- Provides attribute 'environment' with value 'prod' but the consumer didn't ask for it
- Provides a library but the consumer didn't ask for it

Note: if I commented out the product flavors and source sets in the build.gradle CycloneDX is able to generate the output file.

@chetan-ansel
Copy link
Author

chetan-ansel commented Jan 9, 2023

I am able to fix this issue by skipping config for flavors like: As in my case flavors are : nonprod and prod
cyclonedxBom {
skipConfigs = [
"debugCompileClasspath",
"debugAndroidTestCompileClasspath",
"debugUnitTestCompileClasspath",
"debugUnitTestRuntimeClasspath",
"releaseUnitTestCompileClasspath",
"releaseUnitTestRuntimeClasspath",
"nonprodDebugCompileClasspath",
"nonprodDebugAndroidTestCompileClasspath",
"nonprodDebugUnitTestCompileClasspath",
"nonprodDebugUnitTestRuntimeClasspath",

"prodDebugCompileClasspath",
"prodDebugAndroidTestCompileClasspath",
"prodDebugUnitTestCompileClasspath",
"prodDebugUnitTestRuntimeClasspath",

"prodReleaseUnitTestCompileClasspath",
"prodReleaseUnitTestRuntimeClasspath",
"nonprodReleaseUnitTestCompileClasspath",
"nonprodReleaseUnitTestRuntimeClasspath"

]
outputName = "bom"
// The file format generated, can be xml, json or all for generating both
outputFormat = "json"
} I hope have it might help others

@skhokhlov skhokhlov added the android Android related issues label Jul 31, 2024
@skhokhlov
Copy link
Member

Main issue: #478

Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
android Android related issues
Projects
None yet
Development

No branches or pull requests

2 participants