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 variants #297

Closed
momalavasi opened this issue May 25, 2023 · 3 comments
Closed

Execution failed for variants #297

momalavasi opened this issue May 25, 2023 · 3 comments
Labels
android Android related issues

Comments

@momalavasi
Copy link

momalavasi commented May 25, 2023

Hi to everyone, I'm facing this problem... I'm working in android studio and I need to run the plugin to get the bom.xml file. What I get is an error due to a variant choice. Here my build.gradle and the error

plugins {
    id 'com.android.application'
    id 'org.cyclonedx.bom' version '1.7.4'
}

/*
cyclonedxBom {
    includeConfigs += ["compileClasspath"]
}
 */

android {
    namespace 'com.example.demo_android_app'
    compileSdk 33

    defaultConfig {
        applicationId "com.example.demo_android_app"
        minSdk 24
        targetSdk 33
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }
    buildFeatures {
        viewBinding true
    }
}

dependencies {
    implementation'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.9.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation 'androidx.navigation:navigation-fragment:2.5.3'
    implementation 'androidx.navigation:navigation-ui:2.5.3'
    implementation 'org.arakhne.afc.core:maths:17.0'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
    implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.2'
}


error :

$ ./gradlew app:cyclonedxBom
> Task :app:cyclonedxBom FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:cyclonedxBom'.
> The consumer was configured to find an API of a component, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release', attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.4.2'. However we cannot choose between the following variants of project :app:
    - Configuration ':app:releaseApiElements' variant android-base-module-metadata declares an API of a component, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.4.2', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release':
        - Unmatched attributes:
            - Provides attribute 'artifactType' with value 'android-base-module-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
            - Doesn't say anything about its target Java environment (preferred optimized for Android)
    - Configuration ':app:releaseApiElements' variant android-feature-all-metadata declares an API of a component, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.4.2', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release':
        - Unmatched attributes:
            - Provides attribute 'artifactType' with value 'android-feature-all-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
            - Doesn't say anything about its target Java environment (preferred optimized for Android)
    - Configuration ':app:releaseApiElements' variant android-feature-res-ap_ declares an API of a component, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.4.2', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release':
        - Unmatched attributes:
            - Provides attribute 'artifactType' with value 'android-feature-res-ap_' 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
            - Doesn't say anything about its target Java environment (preferred optimized for Android)
    - Configuration ':app:releaseApiElements' variant android-feature-signing-config-data declares an API of a component, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.4.2', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release':
        - Unmatched attributes:
            - Provides attribute 'artifactType' with value 'android-feature-signing-config-data' 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
            - Doesn't say anything about its target Java environment (preferred optimized for Android)
    - Configuration ':app:releaseApiElements' variant android-feature-signing-config-versions declares an API of a component, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.4.2', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release':
        - Unmatched attributes:
            - Provides attribute 'artifactType' with value 'android-feature-signing-config-versions' 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
            - Doesn't say anything about its target Java environment (preferred optimized for Android)
    - Configuration ':app:releaseApiElements' variant android-java-res declares an API of a component, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.4.2', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release':
        - 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
            - Doesn't say anything about its target Java environment (preferred optimized for Android)
    - Configuration ':app:releaseApiElements' variant android-manifest-metadata declares an API of a component, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.4.2', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release':
        - Unmatched attributes:
            - Provides attribute 'artifactType' with value 'android-manifest-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
            - Doesn't say anything about its target Java environment (preferred optimized for Android)

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.5/userguide/command_line_interface.html#sec:command_line_warnings

If I remove the comments for

cyclonedxBom {
    includeConfigs += ["compileClasspath"]
}

I remove also the error, but the file I obtain doesn't present the list of dependencies...
$ cat app/build/reports/bom.xml

<?xml` version="1.0" encoding="UTF-8"?>
<bom version="1" xmlns="http://cyclonedx.org/schema/bom/1.4">
  <metadata>
    <timestamp>2023-05-25T14:23:55Z</timestamp>
    <tools>
      <tool>
        <vendor>CycloneDX</vendor>
        <name>cyclonedx-gradle-plugin</name>
        <version>1.6.1</version>
      </tool>
    </tools>
    <component type="application" bom-ref="pkg:maven/demo-android-app/app@unspecified">
      <group>demo-android-app</group>
      <name>app</name>
      <version>unspecified</version>
      <purl>pkg:maven/demo-android-app/app@unspecified</purl>
    </component>
  </metadata>
</bom>
@momalavasi
Copy link
Author

I followed this #256 (comment) and I resolved.
thank you

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 Jul 31, 2024
@skhokhlov
Copy link
Member

Main issue: #478

@skhokhlov skhokhlov added the android Android related issues label Jul 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