我试图从我的 Android 项目中排除依赖项,但我做不到。我尝试这样做的原因主要是因为我将这个项目构建为 apk,并且我不想拥有这些 gradle 依赖项。
所以,我需要排除的依赖项是 -> androidx.appcompat:appcompat:1.6.1.
运行此命令(./gradlew :app:internal:dependencies --configuration releaseRuntimeClasspath )来查看依赖树。
+--- project :utils
| | | | +--- androidx.databinding:databinding-common:7.4.2
| | | | +--- androidx.databinding:databinding-runtime:7.4.2 (*)
| | | | +--- androidx.databinding:databinding-adapters:7.4.2 (*)
| | | | +--- androidx.databinding:databinding-ktx:7.4.2 (*)
| | | | +--- project :logger:public
| | | | | \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22 -> 1.9.0 (*)
| | | | +--- project :legacy:model:core (*)
| | | | +--- project :others:io
| | | | | +--- project :others:io:files
| | | | | | +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22 -> 1.9.0 (*)
| | | | | | \--- project :others:bytes
| | | | | | \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22 -> 1.9.0 (*)
| | | | | +--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.22 -> 1.9.0 (*)
| | | | | \--- project :others:bytes (*)
| | | | +--- project :others:bytes (*)
| | | | +--- com.google.code.gson:gson:2.10.1
| | | | +--- io.insert-koin:koin-core:3.5.0 (*)
| | | | +--- io.insert-koin:koin-android:3.5.0
| | | | | +--- io.insert-koin:koin-core:3.5.0 (*)
| | | | | +--- androidx.appcompat:appcompat:1.6.1
| | | | | | +--- androidx.activity:activity:1.6.0 -> 1.7.2
| | | | | | | +--- androidx.annotation:annotation:1.1.0 -> 1.7.1 (*)
| | | | | | | +--- androidx.collection:collection:1.0.0 -> 1.1.0 (*)
| | | | | | | +--- androidx.core:core:1.8.0 -> 1.9.0
| | | | | | | | +--- androidx.annotation:annotation:1.2.0 -> 1.7.1 (*)
| | | | | | | | +--- androidx.annotation:annotation-experimental:1.3.0
| | | | | | | | | \--- org.jetbrains.kotlin:kotlin-stdlib:1.7.10 -> 1.9.0 (*)
| | | | | | | | +--- androidx.collection:collection:1.0.0 -> 1.1.0 (*)
| | | | | | | | +--- androidx.concurrent:concurrent-futures:1.0.0 -> 1.1.0 (*)
| | | | | | | | +--- androidx.lifecycle:lifecycle-runtime:2.3.1 -> 2.6.1 (*)
| | | | | | | | +--- androidx.versionedparcelable:versionedparcelable:1.1.1
| | | | | | | | | +--- androidx.annotation:annotation:1.1.0 -> 1.7.1 (*)
| | | | | | | | | \--- androidx.collection:collection:1.0.0 -> 1.1.0 (*)
| | | | | | | | \--- androidx.core:core-ktx:1.9.0 (c)
| | | | | | | +--- androidx.lifecycle:lifecycle-runtime:2.6.1 (*)
| | | | | | | +--- androidx.lifecycle:lifecycle-viewmodel:2.6.1 (*)
| | | | | | | +--- androidx.lifecycle:lifecycle-viewmodel-savedstate:2.6.1
| | | | | | | | +--- androidx.annotation:annotation:1.0.0 -> 1.7.1 (*)
| | | | | | | | +--- androidx.core:core-ktx:1.2.0 -> 1.9.0
| | | | | | | | | +--- androidx.annotation:annotation:1.1.0 -> 1.7.1 (*)
| | | | | | | | | +--- androidx.core:core:1.9.0 (*)
| | | | | | | | | +--- org.jetbrains.kotlin:kotlin-stdlib:1.7.10 -> 1.9.0 (*)
| | | | | | | | | \--- androidx.core:core:1.9.0 (c)
| | | | | | | | +--- androidx.lifecycle:lifecycle-livedata-core:2.6.1 (*)
| | | | | | | | +--- androidx.lifecycle:lifecycle-viewmodel:2.6.1 (*)
| | | | | | | | +--- androidx.savedstate:savedstate:1.2.1
| | | | | | | | | +--- androidx.annotation:annotation:1.1.0 -> 1.7.1 (*)
| | | | | | | | | +--- androidx.arch.core:core-common:2.1.0 -> 2.2.0 (*)
| | | | | | | | | +--- androidx.lifecycle:lifecycle-common:2.6.1 (*)
| | | | | | | | | +--- org.jetbrains.kotlin:kotlin-stdlib:1.8.10 -> 1.9.0 (*)
| | | | | | | | | \--- androidx.savedstate:savedstate-ktx:1.2.1 (c)
| | | | | | | | +--- org.jetbrains.kotlin:kotlin-stdlib:1.8.10 -> 1.9.0 (*)
| | | | | | | | +--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4 -> 1.7.1 (*)
| | | | | | | | +--- androidx.lifecycle:lifecycle-common:2.6.1 (c)
| | | | | | | | +--- androidx.lifecycle:lifecycle-common-java8:2.6.1 (c)
| | | | | | | | +--- androidx.lifecycle:lifecycle-livedata:2.6.1 (c)
| | | | | | | | +--- androidx.lifecycle:lifecycle-livedata-core:2.6.1 (c)
| | | | | | | | +--- androidx.lifecycle:lifecycle-livedata-core-ktx:2.6.1 (c)
| | | | | | | | +--- androidx.lifecycle:lifecycle-process:2.6.1 (c)
| | | | | | | | +--- androidx.lifecycle:lifecycle-runtime:2.6.1 (c)
| | | | | | | | +--- androidx.lifecycle:lifecycle-runtime-ktx:2.6.1 (c)
| | | | | | | | +--- androidx.lifecycle:lifecycle-service:2.6.1 (c)
| | | | | | | | +--- androidx.lifecycle:lifecycle-viewmodel:2.6.1 (c)
| | | | | | | | \--- androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1 (c)
| | | | | | | +--- androidx.profileinstaller:profileinstaller:1.3.0 (*)
| | | | | | | +--- androidx.savedstate:savedstate:1.2.1 (*)
| | | | | | | +--- androidx.tracing:tracing:1.0.0 (*)
| | | | | | | +--- org.jetbrains.kotlin:kotlin-stdlib:1.8.10 -> 1.9.0 (*)
| | | | | | | \--- androidx.activity:activity-ktx:1.7.2 (c)
| | | | | | +--- androidx.annotation:annotation:1.3.0 -> 1.7.1 (*)
| | | | | | +--- androidx.appcompat:appcompat-resources:1.6.1
| | | | | | | +--- androidx.annotation:annotation:1.2.0 -> 1.7.1 (*)
| | | | | | | +--- androidx.collection:collection:1.0.0 -> 1.1.0 (*)
| | | | | | | +--- androidx.core:core:1.6.0 -> 1.9.0 (*)
| | | | | | | +--- androidx.vectordrawable:vectordrawable:1.1.0
| | | | | | | | +--- androidx.annotation:annotation:1.1.0 -> 1.7.1 (*)
| | | | | | | | +--- androidx.core:core:1.1.0 -> 1.9.0 (*)
| | | | | | | | \--- androidx.collection:collection:1.1.0 (*)
| | | | | | | +--- androidx.vectordrawable:vectordrawable-animated:1.1.0
| | | | | | | | +--- androidx.vectordrawable:vectordrawable:1.1.0 (*)
| | | | | | | | +--- androidx.interpolator:interpolator:1.0.0
| | | | | | | | | \--- androidx.annotation:annotation:1.0.0 -> 1.7.1 (*)
| | | | | | | | \--- androidx.collection:collection:1.1.0 (*)
| | | | | | | \--- androidx.appcompat:appcompat:1.6.1 (c)
| | | | | | +--- androidx.collection:collection:1.0.0 -> 1.1.0 (*)
| | | | | | +--- androidx.core:core:1.9.0 (*)
| | | | | | +--- androidx.core:core-ktx:1.8.0 -> 1.9.0 (*)
| | | | | | +--- androidx.cursoradapter:cursoradapter:1.0.0
| | | | | | | \--- androidx.annotation:annotation:1.0.0 -> 1.7.1 (*)
| | | | | | +--- androidx.drawerlayout:drawerlayout:1.0.0 -> 1.1.1
| | | | | | | +--- androidx.annotation:annotation:1.1.0 -> 1.7.1 (*)
| | | | | | | +--- androidx.core:core:1.2.0 -> 1.9.0 (*)
| | | | | | | \--- androidx.customview:customview:1.1.0
| | | | | | | +--- androidx.annotation:annotation:1.1.0 -> 1.7.1 (*)
| | | | | | | +--- androidx.core:core:1.3.0 -> 1.9.0 (*)
| | | | | | | \--- androidx.collection:collection:1.1.0 (*)
| | | | | | +--- androidx.emoji2:emoji2:1.2.0
| | | | | | | +--- androidx.annotation:annotation:1.2.0 -> 1.7.1 (*)
| | | | | | | +--- androidx.collection:collection:1.1.0 (*)
| | | | | | | +--- androidx.core:core:1.3.0 -> 1.9.0 (*)
| | | | | | | +--- androidx.lifecycle:lifecycle-process:2.4.1 -> 2.6.1 (*)
| | | | | | | \--- androidx.startup:startup-runtime:1.0.0 -> 1.1.1 (*)
| | | | | | +--- androidx.emoji2:emoji2-views-helper:1.2.0
| | | | | | | +--- androidx.collection:collection:1.1.0 (*)
| | | | | | | +--- androidx.core:core:1.3.0 -> 1.9.0 (*)
| | | | | | | \--- androidx.emoji2:emoji2:1.2.0 (*)
| | | | | | +--- androidx.fragment:fragment:1.3.6 -> 1.6.1
| | | | | | | +--- androidx.activity:activity:1.7.2 (*)
| | | | | | | +--- androidx.annotation:annotation:1.1.0 -> 1.7.1 (*)
| | | | | | | +--- androidx.annotation:annotation-experimental:1.0.0 -> 1.3.0 (*)
| | | | | | | +--- androidx.collection:collection:1.1.0 (*)
| | | | | | | +--- androidx.core:core-ktx:1.2.0 -> 1.9.0 (*)
| | | | | | | +--- androidx.lifecycle:lifecycle-livedata-core:2.6.1 (*)
| | | | | | | +--- androidx.lifecycle:lifecycle-runtime:2.6.1 (*)
| | | | | | | +--- androidx.lifecycle:lifecycle-viewmodel:2.6.1 (*)
| | | | | | | +--- androidx.lifecycle:lifecycle-viewmodel-savedstate:2.6.1 (*)
| | | | | | | +--- androidx.loader:loader:1.0.0
| | | | | | | | +--- androidx.annotation:annotation:1.0.0 -> 1.7.1 (*)
| | | | | | | | +--- androidx.core:core:1.0.0 -> 1.9.0 (*)
| | | | | | | | +--- androidx.lifecycle:lifecycle-livedata:2.0.0 -> 2.6.1 (*)
| | | | | | | | \--- androidx.lifecycle:lifecycle-viewmodel:2.0.0 -> 2.6.1 (*)
| | | | | | | +--- androidx.profileinstaller:profileinstaller:1.3.0 (*)
| | | | | | | +--- androidx.savedstate:savedstate:1.2.1 (*)
| | | | | | | +--- androidx.viewpager:viewpager:1.0.0
| | | | | | | | +--- androidx.annotation:annotation:1.0.0 -> 1.7.1 (*)
| | | | | | | | +--- androidx.core:core:1.0.0 -> 1.9.0 (*)
| | | | | | | | \--- androidx.customview:customview:1.0.0 -> 1.1.0 (*)
| | | | | | | +--- org.jetbrains.kotlin:kotlin-stdlib:1.8.20 -> 1.9.0 (*)
| | | | | | | \--- androidx.fragment:fragment-ktx:1.6.1 (c)
| | | | | | +--- androidx.lifecycle:lifecycle-runtime:2.5.1 -> 2.6.1 (*)
| | | | | | +--- androidx.lifecycle:lifecycle-viewmodel:2.5.1 -> 2.6.1 (*)
| | | | | | +--- androidx.resourceinspection:resourceinspection-annotation:1.0.1
| | | | | | | \--- androidx.annotation:annotation:1.1.0 -> 1.7.1 (*)
| | | | | | +--- androidx.savedstate:savedstate:1.2.0 -> 1.2.1 (*)
| | | | | | +--- org.jetbrains.kotlin:kotlin-stdlib:1.7.10 -> 1.9.0 (*)
| | | | | | \--- androidx.appcompat:appcompat-resources:1.6.1 (c)
| | | | | +--- androidx.activity:activity-ktx:1.7.2
| | | | | | +--- androidx.activity:activity:1.7.2 (*)
| | | | | | +--- androidx.core:core-ktx:1.1.0 -> 1.9.0 (*)
| | | | | | +--- androidx.lifecycle:lifecycle-runtime-ktx:2.6.1 (*)
| | | | | | +--- androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1
| | | | | | | +--- androidx.lifecycle:lifecycle-viewmodel:2.6.1 (*)
| | | | | | | +--- org.jetbrains.kotlin:kotlin-stdlib:1.8.10 -> 1.9.0 (*)
| | | | | | | +--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4 -> 1.7.1 (*)
| | | | | | | +--- androidx.lifecycle:lifecycle-common:2.6.1 (c)
| | | | | | | +--- androidx.lifecycle:lifecycle-livedata:2.6.1 (c)
| | | | | | | +--- androidx.lifecycle:lifecycle-process:2.6.1 (c)
| | | | | | | +--- androidx.lifecycle:lifecycle-runtime:2.6.1 (c)
| | | | | | | +--- androidx.lifecycle:lifecycle-runtime-ktx:2.6.1 (c)
| | | | | | | +--- androidx.lifecycle:lifecycle-service:2.6.1 (c)
| | | | | | | +--- androidx.lifecycle:lifecycle-viewmodel:2.6.1 (c)
| | | | | | | +--- androidx.lifecycle:lifecycle-common-java8:2.6.1 (c)
| | | | | | | +--- androidx.lifecycle:lifecycle-livedata-core-ktx:2.6.1 (c)
| | | | | | | +--- androidx.lifecycle:lifecycle-viewmodel-savedstate:2.6.1 (c)
| | | | | | | \--- androidx.lifecycle:lifecycle-livedata-core:2.6.1 (c)
| | | | | | +--- androidx.savedstate:savedstate-ktx:1.2.1
| | | | | | | +--- androidx.savedstate:savedstate:1.2.1 (*)
| | | | | | | +--- org.jetbrains.kotlin:kotlin-stdlib:1.8.10 -> 1.9.0 (*)
| | | | | | | \--- androidx.savedstate:savedstate:1.2.1 (c)
| | | | | | +--- org.jetbrains.kotlin:kotlin-stdlib:1.8.10 -> 1.9.0 (*)
| | | | | | \--- androidx.activity:activity:1.7.2 (c)
| | | | | +--- androidx.fragment:fragment-ktx:1.6.1
| | | | | | +--- androidx.activity:activity-ktx:1.5.1 -> 1.7.2 (*)
| | | | | | +--- androidx.collection:collection-ktx:1.1.0
| | | | | | | +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.20 -> 1.9.0 (*)
| | | | | | | \--- androidx.collection:collection:1.1.0 (*)
| | | | | | +--- androidx.core:core-ktx:1.2.0 -> 1.9.0 (*)
| | | | | | +--- androidx.fragment:fragment:1.6.1 (*)
| | | | | | +--- androidx.lifecycle:lifecycle-livedata-core-ktx:2.6.1
| | | | | | | +--- androidx.lifecycle:lifecycle-livedata-core:2.6.1 (*)
| | | | | | | +--- org.jetbrains.kotlin:kotlin-stdlib:1.8.10 -> 1.9.0 (*)
| | | | | | | +--- androidx.lifecycle:lifecycle-common:2.6.1 (c)
| | | | | | | +--- androidx.lifecycle:lifecycle-common-java8:2.6.1 (c)
| | | | | | | +--- androidx.lifecycle:lifecycle-livedata:2.6.1 (c)
| | | | | | | +--- androidx.lifecycle:lifecycle-livedata-core:2.6.1 (c)
| | | | | | | +--- androidx.lifecycle:lifecycle-process:2.6.1 (c)
| | | | | | | +--- androidx.lifecycle:lifecycle-runtime:2.6.1 (c)
| | | | | | | +--- androidx.lifecycle:lifecycle-runtime-ktx:2.6.1 (c)
| | | | | | | +--- androidx.lifecycle:lifecycle-service:2.6.1 (c)
| | | | | | | +--- androidx.lifecycle:lifecycle-viewmodel:2.6.1 (c)
| | | | | | | +--- androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1 (c)
| | | | | | | \--- androidx.lifecycle:lifecycle-viewmodel-savedstate:2.6.1 (c)
| | | | | | +--- androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1 (*)
| | | | | | +--- androidx.savedstate:savedstate-ktx:1.2.1 (*)
| | | | | | +--- org.jetbrains.kotlin:kotlin-stdlib:1.8.20 -> 1.9.0 (*)
| | | | | | \--- androidx.fragment:fragment:1.6.1 (c)
| | | | | +--- androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1 (*)
| | | | | +--- androidx.lifecycle:lifecycle-common-java8:2.6.1
| | | | | | +--- androidx.annotation:annotation:1.1.0 -> 1.7.1 (*)
| | | | | | +--- androidx.lifecycle:lifecycle-common:2.6.1 (*)
| | | | | | +--- androidx.lifecycle:lifecycle-common:2.6.1 (c)
| | | | | | +--- androidx.lifecycle:lifecycle-livedata:2.6.1 (c)
| | | | | | +--- androidx.lifecycle:lifecycle-livedata-core:2.6.1 (c)
| | | | | | +--- androidx.lifecycle:lifecycle-livedata-core-ktx:2.6.1 (c)
| | | | | | +--- androidx.lifecycle:lifecycle-process:2.6.1 (c)
| | | | | | +--- androidx.lifecycle:lifecycle-runtime:2.6.1 (c)
| | | | | | +--- androidx.lifecycle:lifecycle-runtime-ktx:2.6.1 (c)
| | | | | | +--- androidx.lifecycle:lifecycle-service:2.6.1 (c)
| | | | | | +--- androidx.lifecycle:lifecycle-viewmodel:2.6.1 (c)
| | | | | | +--- androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1 (c)
| | | | | | \--- androidx.lifecycle:lifecycle-viewmodel-savedstate:2.6.1 (c)
| | | | | \--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.0 (*)
| | | | +--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.22 -> 1.9.0 (*)
| | | | +--- com.google.android.gms:play-services-location:21.0.1
| | | | | +--- com.google.android.gms:play-services-base:18.1.0
| | | | | | +--- androidx.collection:collection:1.0.0 -> 1.1.0 (*)
| | | | | | +--- androidx.core:core:1.2.0 -> 1.9.0 (*)
| | | | | | +--- androidx.fragment:fragment:1.0.0 -> 1.6.1 (*)
| | | | | | +--- com.google.android.gms:play-services-basement:18.1.0
| | | | | | | +--- androidx.collection:collection:1.0.0 -> 1.1.0 (*)
| | | | | | | +--- androidx.core:core:1.2.0 -> 1.9.0 (*)
| | | | | | | \--- androidx.fragment:fragment:1.0.0 -> 1.6.1 (*)
| | | | | | \--- com.google.android.gms:play-services-tasks:18.0.2
| | | | | | \--- com.google.android.gms:play-services-basement:18.1.0 (*)
| | | | | +--- com.google.android.gms:play-services-basement:18.1.0 (*)
| | | | | \--- com.google.android.gms:play-services-tasks:18.0.2 (*)
| | | | \--- io.github.binaryfoo:emv-bertlv:0.1.8 (*)
这是模块的buld gradle(:utils),其中我无法排除依赖性->
apply from: "../common-android-library-config.gradle"
apply plugin: 'maven-publish'
apply plugin: 'kotlin-kapt'
apply from: '../maven-publication.gradle'
android {
configurations {
all*.exclude group: 'androidx.appcompat', module:'appcompat'
}
buildTypes {
release {
debuggable false
}
development {
debuggable false
matchingFallbacks = ['release']
}
}
}
dependencies {
//testing
androidTestImplementation "androidx.test:runner:$testRunnerVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
testImplementation "junit:junit:$jUnitVersion"
testImplementation "org.mockito:mockito-core:$mockitoCoreVesion"
testImplementation "org.mockito:mockito-inline:$mockitoInlineVersion"
testImplementation "org.mockito.kotlin:mockito-kotlin:$mockitoKotlinVersion"
testImplementation "androidx.arch.core:core-testing:$archCoreTestingVersion"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$kotlinCoroutinesTestVersion"
//android x
compileOnly ("androidx.activity:activity-ktx:$activityKtxVersion")
//gson
implementation "com.google.code.gson:gson:$gsonVersion"
//joda
compileOnly "net.danlew:android.joda:2.10.7.2"
//koin
implementation "io.insert-koin:koin-core:$koinVersion"
// HERE WHERE IM TRYING TO EXCLUDE
implementation ("io.insert-koin:koin-android:$koinVersion"){
exclude group: 'androidx.appcompat', module: 'appcompat'
}
compileOnly "androidx.appcompat:appcompat:$appcompatVersion"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinStdlibJdk7Version"
implementation "com.google.android.gms:play-services-location:$locationVersion"
implementation "io.github.binaryfoo:emv-bertlv:$emvBerTlvVersion"
}
afterEvaluate {
publishing {
registerMavenPublishing(it, moduleVersion, "../", "utils", "com.geopagos.cps")
}
}
我做错了什么?
提前致谢!
您可以像这样使用排除块 -
示例:
exclude group: 'androidx.appcompat', module: 'appcompat'
你的 gradle 文件看起来像这样 -
implementation ('androidx.appcompat:appcompat:1.6.1') {
exclude group: 'androidx.appcompat', module: 'appcompat'
.....rest of code