Java Android Studio错误:类Android.support.v4.hardware.display.DisplayManagerCompat已添加到输出中。请删除重复的副本

Java Android Studio错误:类Android.support.v4.hardware.display.DisplayManagerCompat已添加到输出中。请删除重复的副本,java,android,android-studio,android-gradle-plugin,Java,Android,Android Studio,Android Gradle Plugin,当我尝试使用android Studio构建我的android项目时,我面临以下异常 Error:Class android.support.v4.hardware.display.DisplayManagerCompat has already been added to output. Please remove duplicate copies. 我在这里尝试了StackOverflow的不同建议,例如排除如下所示的包,但仍然是一样的: dependencies { depend

当我尝试使用android Studio构建我的android项目时,我面临以下异常

Error:Class android.support.v4.hardware.display.DisplayManagerCompat has already been added to output. Please remove duplicate copies.
我在这里尝试了StackOverflow的不同建议,例如排除如下所示的包,但仍然是一样的:

dependencies {
    dependencies {
        //compile project(':android-beacon-library')
        compile 'org.altbeacon:android-beacon-library:2+@aar'
        compile 'com.squareup.okhttp:okhttp:2.1.0'
        compile ('com.squareup.picasso:picasso:2.2.0') {
            exclude group: 'android.support', module: 'library'
        }
        compile 'com.google.code.gson:gson:2.2.4'
        compile('com.github.Comcast:FreeFlow:v-0.6') {
            exclude group: 'android.support', module: 'library'
        }
    }
}
使用gradlew.bat命令,我尝试查找重复的条目,但在命令的输出中它不存在,下面粘贴的是
gradlew.bat:app:dependencies

------------------------------------------------------------
Project :app
------------------------------------------------------------

_debugApk - ## Internal use, do not manually configure ##
+--- org.altbeacon:android-beacon-library:2+ -> 2.3.3
+--- com.squareup.okhttp:okhttp:2.1.0
|    \--- com.squareup.okio:okio:1.0.1
+--- com.squareup.picasso:picasso:2.2.0
+--- com.google.code.gson:gson:2.2.4
\--- com.github.Comcast:FreeFlow:v-0.6
     \--- com.android.support:support-v4:22.1.0
          \--- com.android.support:support-annotations:22.1.0

_debugCompile - ## Internal use, do not manually configure ##
+--- org.altbeacon:android-beacon-library:2+ -> 2.3.3
+--- com.squareup.okhttp:okhttp:2.1.0
|    \--- com.squareup.okio:okio:1.0.1
+--- com.squareup.picasso:picasso:2.2.0
+--- com.google.code.gson:gson:2.2.4
\--- com.github.Comcast:FreeFlow:v-0.6
     \--- com.android.support:support-v4:22.1.0
          \--- com.android.support:support-annotations:22.1.0

_debugTestApk - ## Internal use, do not manually configure ##
No dependencies

_debugTestCompile - ## Internal use, do not manually configure ##
No dependencies

_releaseApk - ## Internal use, do not manually configure ##
+--- org.altbeacon:android-beacon-library:2+ -> 2.3.3
+--- com.squareup.okhttp:okhttp:2.1.0
|    \--- com.squareup.okio:okio:1.0.1
+--- com.squareup.picasso:picasso:2.2.0
+--- com.google.code.gson:gson:2.2.4
\--- com.github.Comcast:FreeFlow:v-0.6
     \--- com.android.support:support-v4:22.1.0
          \--- com.android.support:support-annotations:22.1.0

_releaseCompile - ## Internal use, do not manually configure ##
+--- org.altbeacon:android-beacon-library:2+ -> 2.3.3
+--- com.squareup.okhttp:okhttp:2.1.0
|    \--- com.squareup.okio:okio:1.0.1
+--- com.squareup.picasso:picasso:2.2.0
+--- com.google.code.gson:gson:2.2.4
\--- com.github.Comcast:FreeFlow:v-0.6
     \--- com.android.support:support-v4:22.1.0
          \--- com.android.support:support-annotations:22.1.0

androidJacocoAgent - The Jacoco agent to use to get coverage data.
\--- org.jacoco:org.jacoco.agent:0.7.1.201405082137

androidJacocoAnt - The Jacoco ant tasks to use to get execute Gradle tasks.
\--- org.jacoco:org.jacoco.ant:0.7.1.201405082137
     +--- org.jacoco:org.jacoco.core:0.7.1.201405082137
     |    \--- org.ow2.asm:asm-debug-all:5.0.1
     +--- org.jacoco:org.jacoco.report:0.7.1.201405082137
     |    +--- org.jacoco:org.jacoco.core:0.7.1.201405082137 (*)
     |    \--- org.ow2.asm:asm-debug-all:5.0.1
     \--- org.jacoco:org.jacoco.agent:0.7.1.201405082137

androidTestApk - Classpath packaged with the compiled 'androidTest' classes.
No dependencies

androidTestCompile - Classpath for compiling the androidTest sources.
No dependencies

androidTestProvided - Classpath for only compiling the androidTest sources.
No dependencies

androidTestWearApp - Link to a wear app to embed for object 'androidTest'.
No dependencies

apk - Classpath packaged with the compiled 'main' classes.
No dependencies

archives - Configuration for archive artifacts.
No dependencies

compile - Classpath for compiling the main sources.
+--- org.altbeacon:android-beacon-library:2+ -> 2.3.3
+--- com.squareup.okhttp:okhttp:2.1.0
|    \--- com.squareup.okio:okio:1.0.1
+--- com.squareup.picasso:picasso:2.2.0
+--- com.google.code.gson:gson:2.2.4
\--- com.github.Comcast:FreeFlow:v-0.6
     \--- com.android.support:support-v4:22.1.0
          \--- com.android.support:support-annotations:22.1.0

debugApk - Classpath packaged with the compiled 'debug' classes.
No dependencies

debugCompile - Classpath for compiling the debug sources.
No dependencies

debugProvided - Classpath for only compiling the debug sources.
No dependencies

debugWearApp - Link to a wear app to embed for object 'debug'.
No dependencies

default - Configuration for default artifacts.
No dependencies

provided - Classpath for only compiling the main sources.
No dependencies

releaseApk - Classpath packaged with the compiled 'release' classes.
No dependencies

releaseCompile - Classpath for compiling the release sources.
No dependencies

releaseProvided - Classpath for only compiling the release sources.
No dependencies

releaseWearApp - Link to a wear app to embed for object 'release'.
No dependencies

wearApp - Link to a wear app to embed for object 'main'.
No dependencies

BUILD SUCCESSFUL

Total time: 9.674 secs

您好,请将此添加到您的gradle文件。这对我很管用。希望它能帮助你!:)


您好,请将此添加到您的gradle文件。这对我很管用。希望它能帮助你!:)


使用--info或--debug选项运行Gradle以找出原因。当您在两个不同的目录中有相同的文件名时(即,在主源代码中,以及在测试源代码/测试IT源代码中的某个地方等),通常会发生这种情况。我还发现,如果您生成了项目中没有.java文件的.class文件,但您在运行中创建了它们(例如:在JIBX/XSL等操作期间创建的),则可以使用--info或--debug选项运行Gradle来找出原因,那么这种情况就会发生。当您在两个不同的目录中有相同的文件名时(即,在主源代码中,以及在测试源代码/测试IT源代码中的某个地方等),通常会发生这种情况。我还发现,如果生成的.class文件在项目中没有.java文件,但您在运行中创建了它们(例如:在JIBX/XSL等操作期间创建),则可以在依赖项之前添加以下代码:配置{all*.exclude group:'com.android.support.v4',模块:'support-v4'在依赖项之前添加以下代码:configurations{all*.exclude group:'com.android.support.v4',module:'support-v4'},并告诉我它是否有效。
compile ('com.android.support:palette-v7:21.0.0'){
    exclude module: 'support-v4'
}