我不是一个非常有经验的Android开发人员,但我想将我们的单个Android项目包含到依赖跟踪安装中。运行cyclonedxBom时,我得到以下错误:
Execution failed for task ':app:cyclonedxBom'.
> Could not resolve all dependencies for configuration ':app:acceptDebugAndroidTestCompileClasspath'.
> 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 'debug', attribute 'version' with value 'accept', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm'. However we cannot choose between the following variants of project :app:
- Configuration ':app:acceptDebugApiElements' variant android-base-module-metadata declares an API of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm', attribute 'version' with value 'accept':
- 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 'acceptDebug' but the consumer didn't ask for it
- Doesn't say anything about its target Java environment (preferred optimized for Android)
...
上述错误在不同的变体中重复。
这是我的build.gradle(敏感信息已删除):
plugins {
id 'io.gitlab.arturbosch.detekt' version '1.5.1'
id 'org.jlleitschuh.gradle.ktlint' version '9.2.1'
id "org.cyclonedx.bom" version "1.1.4"
id 'com.github.mkep-dev.dependency-track-bom-publish' version "0.1.2"
}
dtrackPublishBom{
host "..."
apiKey "."
projectUuid "..."
}
publishBom.dependsOn(cyclonedxBom)
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: "androidx.navigation.safeargs.kotlin"
apply plugin: 'kotlin-kapt'
android {
signingConfigs {
release {
storeFile file('...')
storePassword '...'
keyPassword '...'
keyAlias = '...'
}
}
compileSdkVersion 30
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.company.appname"
minSdkVersion 23
targetSdkVersion 30
versionCode 27
versionName "1.0.7"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
minifyEnabled false
}
release {
minifyEnabled true
signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
flavorDimensions "version"
productFlavors {
internal {
dimension "version"
applicationIdSuffix ".internal"
versionNameSuffix "-internal"
resValue "string", "app_name", "AppName- Internal"
buildConfigField "long", "NETWORK_CONNECT_TIMEOUT", '10'
buildConfigField "long", "NETWORK_READ_TIMEOUT", '30'
buildConfigField "String", "WEB_BASE_URL", '"..."'
buildConfigField "String", "API_BASE_URL", '"..."'
buildConfigField "String", "API_OAUTH_BASE_URL", '"..."'
buildConfigField "String", "API_OAUTH_CLIENT_ID", '"."'
buildConfigField "String", "API_OAUTH_CLIENT_SECRET", '"..."'
buildConfigField "String", "API_OAUTH_SCOPE", '""'
buildConfigField "int", "API_OAUTH_RE_AUTH_RETRY_LIMIT", '1'
resValue "string", "google_maps_api_key", "..."
}
accept {
dimension "version"
applicationIdSuffix ".accept"
versionNameSuffix "-accept"
resValue "string", "app_name", "AppName - Accept"
buildConfigField "long", "NETWORK_CONNECT_TIMEOUT", '10'
buildConfigField "long", "NETWORK_READ_TIMEOUT", '30'
buildConfigField "String", "WEB_BASE_URL", '"..."'
buildConfigField "String", "API_BASE_URL", '"..."'
buildConfigField "String", "API_OAUTH_BASE_URL", '"..."'
buildConfigField "String", "API_OAUTH_CLIENT_ID", '"."'
buildConfigField "String", "API_OAUTH_CLIENT_SECRET", '"..."'
buildConfigField "String", "API_OAUTH_SCOPE", '""'
buildConfigField "int", "API_OAUTH_RE_AUTH_RETRY_LIMIT", '1'
resValue "string", "google_maps_api_key", "..."
}
prod {
dimension "version"
applicationIdSuffix ""
versionNameSuffix ""
resValue "string", "app_name", "AppName"
buildConfigField "long", "NETWORK_CONNECT_TIMEOUT", '10'
buildConfigField "long", "NETWORK_READ_TIMEOUT", '30'
buildConfigField "String", "WEB_BASE_URL", '"..."'
buildConfigField "String", "API_BASE_URL", '"..."'
buildConfigField "String", "API_OAUTH_BASE_URL", '"..."'
buildConfigField "String", "API_OAUTH_CLIENT_ID", '"."'
buildConfigField "String", "API_OAUTH_CLIENT_SECRET", '"..."'
buildConfigField "String", "API_OAUTH_SCOPE", '""'
buildConfigField "int", "API_OAUTH_RE_AUTH_RETRY_LIMIT", '1'
resValue "string", "google_maps_api_key", "..."
}
}
}
dependencies {
def room_version = '2.2.6'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.navigation:navigation-fragment:2.3.0'
implementation 'androidx.navigation:navigation-ui:2.3.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.0'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.google.android.gms:play-services-location:18.0.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
//update to map utils 1.1 is breaking
implementation 'com.google.maps.android:android-maps-utils:0.6.2'
implementation 'com.github.pengrad:mapscaleview:1.5.0'
implementation 'com.karumi:dexter:6.2.2'
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-ktx:$room_version"
implementation "androidx.room:room-rxjava2:$room_version"
implementation 'com.squareup.okhttp3:okhttp:4.8.0'
implementation 'com.squareup.okhttp3:logging-interceptor:4.8.0'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1'
implementation 'com.airbnb.android:lottie:3.6.1'
implementation 'com.google.dagger:dagger:2.28.1'
implementation 'com.google.dagger:dagger-android-support:2.28.1'
kapt 'com.google.dagger:dagger-compiler:2.28.1'
kapt 'com.google.dagger:dagger-android-processor:2.28.1'
compileOnly 'javax.annotation:jsr250-api:1.0'
implementation 'com.jakewharton.timber:timber:4.7.1'
implementation 'online.devliving:securedpreferencestore:0.7.4'
implementation 'com.github.bumptech.glide:glide:4.12.0'
kapt 'com.github.bumptech.glide:compiler:4.12.0'
implementation 'com.github.pthomain:dejavu:2.0.0-beta13'
detektPlugins "io.gitlab.arturbosch.detekt:detekt-formatting:1.5.1"
implementation 'com.jakewharton.threetenabp:threetenabp:1.3.0'
implementation 'androidx.work:work-runtime-ktx:2.5.0'
implementation "androidx.work:work-rxjava2:2.5.0"
implementation "com.github.ChiliLabs:ChiliPhotoPicker:0.3.1"
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'
implementation 'androidx.preference:preference-ktx:1.1.1'
implementation 'androidx.browser:browser:1.3.0'
implementation 'com.google.firebase:firebase-analytics:18.0.2'
implementation 'com.google.firebase:firebase-crashlytics:17.4.0'
}
有人能给我指个路吗?
2条答案
按热度按时间h6my8fg21#
我也遇到了同样的问题,我添加了一些以下代码来解决:
kmynzznz2#
如果您有多个构建变体,则必须在
includeConfigs
属性中定义一个。对于如果你有一个构建变体fooDebug
,像这样定义它: