gpt4 book ai didi

Android Studio依赖冲突(程序类型已经存在)

转载 作者:行者123 更新时间:2023-11-29 23:43:38 28 4
gpt4 key购买 nike

我的项目中有一个 RecyclerView,但我无法构建它。

这是我的 build.gradle 文件:

apply plugin: 'com.android.application'

android {
compileSdkVersion 27
defaultConfig {
applicationId "app_name"
minSdkVersion 27
targetSdkVersion 27
versionCode 5
versionName "1.0.4"
}
buildTypes {
release {
initWith(buildTypes.debug)
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}

dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:recyclerview-v7:27.1.1'
// implementation 'com.android.support:support-v4:27.1.1'
testImplementation 'junit:junit:4.12'
compileOnly 'com.google.android.things:androidthings:1.0'
implementation 'com.google.android.things.contrib:driver-bmx280:1.0'
implementation 'com.google.android.things.contrib:driver-button:1.0'
implementation 'com.google.android.things:cloud-iot-core:1.0.0'
implementation 'com.eclipsesource.minimal-json:minimal-json:0.9.5'
}

当我构建时,我从这三个消息中添加一个:

Program type already present: android.support.v4.content.Loader Message{kind=ERROR, text=Program type already present: android.support.v4.content.Loader, sources=[Unknown source file], tool name=Optional.of(D8)}

Program type already present: android.support.v4.app.TaskStackBuilder Message{kind=ERROR, text=Program type already present: android.support.v4.app.TaskStackBuilder, sources=[Unknown source file], tool name=Optional.of(D8)}

Program type already present: android.support.v4.content.LocalBroadcastManager$ReceiverRecord Message{kind=ERROR, text=Program type already present: android.support.v4.content.LocalBroadcastManager$ReceiverRecord, sources=[Unknown source file], tool name=Optional.of(D8)}

我试图排除这种依赖:

implementation ('com.android.support:recyclerview-v7:27.1.1') {
exclude group: 'com.android.support', module: 'support-v4'
exclude module: 'android.support.v4.content.Loader'
exclude module: 'android.support.v4.content.LocalBroadcastManager$ReceiverRecord'
exclude module: 'android.support.v4.app.TaskStackBuilder'
}

但我仍然有同样的错误。我该如何解决这个问题?

编辑:我在 Android Studio 中做了一个 androidDependencies 并获得了这个:

Executing tasks: [androidDependencies]

Configuration on demand is an incubating feature.
:app:androidDependencies
debug
debugCompileClasspath - Dependencies for compilation
+--- com.google.android.things:androidthings:1.0@jar
+--- com.android.support.constraint:constraint-layout:1.1.2@aar
+--- com.android.support:recyclerview-v7:27.1.1@aar
+--- com.android.support:support-v4:27.1.1@aar
+--- com.google.android.things.contrib:driver-bmx280:1.0@aar
+--- com.google.android.things.contrib:driver-button:1.0@aar
+--- com.google.android.things:cloud-iot-core:1.0.0@aar
+--- com.eclipsesource.minimal-json:minimal-json:0.9.5@jar
+--- com.android.support:multidex:1.0.3@aar
+--- com.android.support.constraint:constraint-layout-solver:1.1.2@jar
+--- com.android.support:support-fragment:27.1.1@aar
+--- com.android.support:support-core-ui:27.1.1@aar
+--- com.android.support:support-media-compat:27.1.1@aar
+--- com.android.support:support-core-utils:27.1.1@aar
+--- com.android.support:support-compat:27.1.1@aar
+--- com.android.support:support-annotations:27.1.1@jar
+--- org.eclipse.paho:org.eclipse.paho.android.service:1.0.2@jar
+--- org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.0@jar
+--- org.bitbucket.b_c:jose4j:0.6.3@jar
+--- android.arch.lifecycle:runtime:1.1.0@aar
+--- android.arch.lifecycle:livedata-core:1.1.0@aar
+--- android.arch.lifecycle:viewmodel:1.1.0@aar
+--- com.google.android:support-v4:r7@jar
+--- org.slf4j:slf4j-api:1.7.21@jar
+--- android.arch.lifecycle:common:1.1.0@jar
+--- android.arch.core:runtime:1.1.0@aar
\--- android.arch.core:common:1.1.0@jar

debugRuntimeClasspath - Dependencies for runtime/packaging
+--- com.android.support.constraint:constraint-layout:1.1.2@aar
+--- com.android.support:recyclerview-v7:27.1.1@aar
+--- com.android.support:support-v4:27.1.1@aar
+--- com.google.android.things.contrib:driver-bmx280:1.0@aar
+--- com.google.android.things.contrib:driver-button:1.0@aar
+--- com.google.android.things:cloud-iot-core:1.0.0@aar
+--- com.eclipsesource.minimal-json:minimal-json:0.9.5@jar
+--- com.android.support:multidex:1.0.3@aar
+--- com.android.support.constraint:constraint-layout-solver:1.1.2@jar
+--- com.android.support:support-fragment:27.1.1@aar
+--- com.android.support:support-core-ui:27.1.1@aar
+--- com.android.support:support-media-compat:27.1.1@aar
+--- com.android.support:support-core-utils:27.1.1@aar
+--- com.android.support:support-compat:27.1.1@aar
+--- com.android.support:support-annotations:27.1.1@jar
+--- org.eclipse.paho:org.eclipse.paho.android.service:1.0.2@jar
+--- org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.0@jar
+--- org.bitbucket.b_c:jose4j:0.6.3@jar
+--- android.arch.lifecycle:runtime:1.1.0@aar
+--- android.arch.lifecycle:livedata-core:1.1.0@aar
+--- android.arch.lifecycle:viewmodel:1.1.0@aar
+--- com.google.android:support-v4:r7@jar
+--- org.slf4j:slf4j-api:1.7.21@jar
+--- android.arch.lifecycle:common:1.1.0@jar
+--- android.arch.core:runtime:1.1.0@aar
\--- android.arch.core:common:1.1.0@jar

debugAndroidTest
debugAndroidTestCompileClasspath - Dependencies for compilation
+--- com.android.support.constraint:constraint-layout:1.1.2@aar
+--- com.android.support:recyclerview-v7:27.1.1@aar
+--- com.android.support:support-v4:27.1.1@aar
+--- com.google.android.things.contrib:driver-bmx280:1.0@aar
+--- com.google.android.things.contrib:driver-button:1.0@aar
+--- com.google.android.things:cloud-iot-core:1.0.0@aar
+--- com.eclipsesource.minimal-json:minimal-json:0.9.5@jar
+--- com.android.support:multidex:1.0.3@aar
+--- com.android.support.constraint:constraint-layout-solver:1.1.2@jar
+--- com.android.support:support-fragment:27.1.1@aar
+--- com.android.support:support-core-ui:27.1.1@aar
+--- com.android.support:support-media-compat:27.1.1@aar
+--- com.android.support:support-core-utils:27.1.1@aar
+--- com.android.support:support-compat:27.1.1@aar
+--- com.android.support:support-annotations:27.1.1@jar
+--- org.eclipse.paho:org.eclipse.paho.android.service:1.0.2@jar
+--- org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.0@jar
+--- org.bitbucket.b_c:jose4j:0.6.3@jar
+--- android.arch.lifecycle:runtime:1.1.0@aar
+--- android.arch.lifecycle:livedata-core:1.1.0@aar
+--- android.arch.lifecycle:viewmodel:1.1.0@aar
+--- com.google.android:support-v4:r7@jar
+--- org.slf4j:slf4j-api:1.7.21@jar
+--- android.arch.lifecycle:common:1.1.0@jar
+--- android.arch.core:runtime:1.1.0@aar
\--- android.arch.core:common:1.1.0@jar

debugAndroidTestRuntimeClasspath - Dependencies for runtime/packaging

debugUnitTest
debugUnitTestCompileClasspath - Dependencies for compilation
+--- com.android.support.constraint:constraint-layout:1.1.2@aar
+--- com.android.support:recyclerview-v7:27.1.1@aar
+--- com.android.support:support-v4:27.1.1@aar
+--- com.google.android.things.contrib:driver-bmx280:1.0@aar
+--- com.google.android.things.contrib:driver-button:1.0@aar
+--- com.google.android.things:cloud-iot-core:1.0.0@aar
+--- com.eclipsesource.minimal-json:minimal-json:0.9.5@jar
+--- com.android.support:multidex:1.0.3@aar
+--- junit:junit:4.12@jar
+--- com.android.support.constraint:constraint-layout-solver:1.1.2@jar
+--- com.android.support:support-fragment:27.1.1@aar
+--- com.android.support:support-core-ui:27.1.1@aar
+--- com.android.support:support-media-compat:27.1.1@aar
+--- com.android.support:support-core-utils:27.1.1@aar
+--- com.android.support:support-compat:27.1.1@aar
+--- com.android.support:support-annotations:27.1.1@jar
+--- org.eclipse.paho:org.eclipse.paho.android.service:1.0.2@jar
+--- org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.0@jar
+--- org.bitbucket.b_c:jose4j:0.6.3@jar
+--- org.hamcrest:hamcrest-core:1.3@jar
+--- android.arch.lifecycle:runtime:1.1.0@aar
+--- android.arch.lifecycle:livedata-core:1.1.0@aar
+--- android.arch.lifecycle:viewmodel:1.1.0@aar
+--- com.google.android:support-v4:r7@jar
+--- org.slf4j:slf4j-api:1.7.21@jar
+--- android.arch.lifecycle:common:1.1.0@jar
+--- android.arch.core:runtime:1.1.0@aar
\--- android.arch.core:common:1.1.0@jar

debugUnitTestRuntimeClasspath - Dependencies for runtime/packaging
+--- com.android.support.constraint:constraint-layout:1.1.2@aar
+--- com.android.support:recyclerview-v7:27.1.1@aar
+--- com.android.support:support-v4:27.1.1@aar
+--- com.google.android.things.contrib:driver-bmx280:1.0@aar
+--- com.google.android.things.contrib:driver-button:1.0@aar
+--- com.google.android.things:cloud-iot-core:1.0.0@aar
+--- com.eclipsesource.minimal-json:minimal-json:0.9.5@jar
+--- com.android.support:multidex:1.0.3@aar
+--- junit:junit:4.12@jar
+--- com.android.support.constraint:constraint-layout-solver:1.1.2@jar
+--- com.android.support:support-fragment:27.1.1@aar
+--- com.android.support:support-core-ui:27.1.1@aar
+--- com.android.support:support-media-compat:27.1.1@aar
+--- com.android.support:support-core-utils:27.1.1@aar
+--- com.android.support:support-compat:27.1.1@aar
+--- com.android.support:support-annotations:27.1.1@jar
+--- org.eclipse.paho:org.eclipse.paho.android.service:1.0.2@jar
+--- org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.0@jar
+--- org.bitbucket.b_c:jose4j:0.6.3@jar
+--- org.hamcrest:hamcrest-core:1.3@jar
+--- android.arch.lifecycle:runtime:1.1.0@aar
+--- android.arch.lifecycle:livedata-core:1.1.0@aar
+--- android.arch.lifecycle:viewmodel:1.1.0@aar
+--- com.google.android:support-v4:r7@jar
+--- org.slf4j:slf4j-api:1.7.21@jar
+--- android.arch.lifecycle:common:1.1.0@jar
+--- android.arch.core:runtime:1.1.0@aar
\--- android.arch.core:common:1.1.0@jar

release
releaseCompileClasspath - Dependencies for compilation
+--- com.google.android.things:androidthings:1.0@jar
+--- com.android.support.constraint:constraint-layout:1.1.2@aar
+--- com.android.support:recyclerview-v7:27.1.1@aar
+--- com.android.support:support-v4:27.1.1@aar
+--- com.google.android.things.contrib:driver-bmx280:1.0@aar
+--- com.google.android.things.contrib:driver-button:1.0@aar
+--- com.google.android.things:cloud-iot-core:1.0.0@aar
+--- com.eclipsesource.minimal-json:minimal-json:0.9.5@jar
+--- com.android.support:multidex:1.0.3@aar
+--- com.android.support.constraint:constraint-layout-solver:1.1.2@jar
+--- com.android.support:support-fragment:27.1.1@aar
+--- com.android.support:support-core-ui:27.1.1@aar
+--- com.android.support:support-media-compat:27.1.1@aar
+--- com.android.support:support-core-utils:27.1.1@aar
+--- com.android.support:support-compat:27.1.1@aar
+--- com.android.support:support-annotations:27.1.1@jar
+--- org.eclipse.paho:org.eclipse.paho.android.service:1.0.2@jar
+--- org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.0@jar
+--- org.bitbucket.b_c:jose4j:0.6.3@jar
+--- android.arch.lifecycle:runtime:1.1.0@aar
+--- android.arch.lifecycle:livedata-core:1.1.0@aar
+--- android.arch.lifecycle:viewmodel:1.1.0@aar
+--- com.google.android:support-v4:r7@jar
+--- org.slf4j:slf4j-api:1.7.21@jar
+--- android.arch.lifecycle:common:1.1.0@jar
+--- android.arch.core:runtime:1.1.0@aar
\--- android.arch.core:common:1.1.0@jar

releaseRuntimeClasspath - Dependencies for runtime/packaging
+--- com.android.support.constraint:constraint-layout:1.1.2@aar
+--- com.android.support:recyclerview-v7:27.1.1@aar
+--- com.android.support:support-v4:27.1.1@aar
+--- com.google.android.things.contrib:driver-bmx280:1.0@aar
+--- com.google.android.things.contrib:driver-button:1.0@aar
+--- com.google.android.things:cloud-iot-core:1.0.0@aar
+--- com.eclipsesource.minimal-json:minimal-json:0.9.5@jar
+--- com.android.support:multidex:1.0.3@aar
+--- com.android.support.constraint:constraint-layout-solver:1.1.2@jar
+--- com.android.support:support-fragment:27.1.1@aar
+--- com.android.support:support-core-ui:27.1.1@aar
+--- com.android.support:support-media-compat:27.1.1@aar
+--- com.android.support:support-core-utils:27.1.1@aar
+--- com.android.support:support-compat:27.1.1@aar
+--- com.android.support:support-annotations:27.1.1@jar
+--- org.eclipse.paho:org.eclipse.paho.android.service:1.0.2@jar
+--- org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.0@jar
+--- org.bitbucket.b_c:jose4j:0.6.3@jar
+--- android.arch.lifecycle:runtime:1.1.0@aar
+--- android.arch.lifecycle:livedata-core:1.1.0@aar
+--- android.arch.lifecycle:viewmodel:1.1.0@aar
+--- com.google.android:support-v4:r7@jar
+--- org.slf4j:slf4j-api:1.7.21@jar
+--- android.arch.lifecycle:common:1.1.0@jar
+--- android.arch.core:runtime:1.1.0@aar
\--- android.arch.core:common:1.1.0@jar

releaseUnitTest
releaseUnitTestCompileClasspath - Dependencies for compilation
+--- com.android.support.constraint:constraint-layout:1.1.2@aar
+--- com.android.support:recyclerview-v7:27.1.1@aar
+--- com.android.support:support-v4:27.1.1@aar
+--- com.google.android.things.contrib:driver-bmx280:1.0@aar
+--- com.google.android.things.contrib:driver-button:1.0@aar
+--- com.google.android.things:cloud-iot-core:1.0.0@aar
+--- com.eclipsesource.minimal-json:minimal-json:0.9.5@jar
+--- com.android.support:multidex:1.0.3@aar
+--- junit:junit:4.12@jar
+--- com.android.support.constraint:constraint-layout-solver:1.1.2@jar
+--- com.android.support:support-fragment:27.1.1@aar
+--- com.android.support:support-core-ui:27.1.1@aar
+--- com.android.support:support-media-compat:27.1.1@aar
+--- com.android.support:support-core-utils:27.1.1@aar
+--- com.android.support:support-compat:27.1.1@aar
+--- com.android.support:support-annotations:27.1.1@jar
+--- org.eclipse.paho:org.eclipse.paho.android.service:1.0.2@jar
+--- org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.0@jar
+--- org.bitbucket.b_c:jose4j:0.6.3@jar
+--- org.hamcrest:hamcrest-core:1.3@jar
+--- android.arch.lifecycle:runtime:1.1.0@aar
+--- android.arch.lifecycle:livedata-core:1.1.0@aar
+--- android.arch.lifecycle:viewmodel:1.1.0@aar
+--- com.google.android:support-v4:r7@jar
+--- org.slf4j:slf4j-api:1.7.21@jar
+--- android.arch.lifecycle:common:1.1.0@jar
+--- android.arch.core:runtime:1.1.0@aar
\--- android.arch.core:common:1.1.0@jar

releaseUnitTestRuntimeClasspath - Dependencies for runtime/packaging
+--- com.android.support.constraint:constraint-layout:1.1.2@aar
+--- com.android.support:recyclerview-v7:27.1.1@aar
+--- com.android.support:support-v4:27.1.1@aar
+--- com.google.android.things.contrib:driver-bmx280:1.0@aar
+--- com.google.android.things.contrib:driver-button:1.0@aar
+--- com.google.android.things:cloud-iot-core:1.0.0@aar
+--- com.eclipsesource.minimal-json:minimal-json:0.9.5@jar
+--- com.android.support:multidex:1.0.3@aar
+--- junit:junit:4.12@jar
+--- com.android.support.constraint:constraint-layout-solver:1.1.2@jar
+--- com.android.support:support-fragment:27.1.1@aar
+--- com.android.support:support-core-ui:27.1.1@aar
+--- com.android.support:support-media-compat:27.1.1@aar
+--- com.android.support:support-core-utils:27.1.1@aar
+--- com.android.support:support-compat:27.1.1@aar
+--- com.android.support:support-annotations:27.1.1@jar
+--- org.eclipse.paho:org.eclipse.paho.android.service:1.0.2@jar
+--- org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.0@jar
+--- org.bitbucket.b_c:jose4j:0.6.3@jar
+--- org.hamcrest:hamcrest-core:1.3@jar
+--- android.arch.lifecycle:runtime:1.1.0@aar
+--- android.arch.lifecycle:livedata-core:1.1.0@aar
+--- android.arch.lifecycle:viewmodel:1.1.0@aar
+--- com.google.android:support-v4:r7@jar
+--- org.slf4j:slf4j-api:1.7.21@jar
+--- android.arch.lifecycle:common:1.1.0@jar
+--- android.arch.core:runtime:1.1.0@aar
\--- android.arch.core:common:1.1.0@jar

BUILD SUCCESSFUL in 0s
1 actionable task: 1 executed
15:29:36: Task execution finished 'androidDependencies'.

最佳答案

答案是写:

implementation ('com.google.android.things:cloud-iot-core:1.0.0') {
exclude module: 'support-v4'
}

'support-v4' 是 cloud-iot-core 的实习生依赖。

关于Android Studio依赖冲突(程序类型已经存在),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51633534/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com