当前位置: 首页 > 知识库问答 >
问题:

构建Android APK时出现DuplicateFileException错误

闻人升
2023-03-14
:app:transformResourcesWithMergeJavaResForDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK com/google/appengine/repackaged/org/apache/commons/codec/language/bm/sep_approx_spanish.txt
File1: C:\Users\USER\.gradle\caches\modules-2\files-2.1\com.google.appengine\appengine-api-1.0-sdk\1.9.28\e92c18272b555027d9ec666e7a89162f10638314\appengine-api-1.0-sdk-1.9.28.jar
File2: C:\Users\USER\.gradle\caches\modules-2\files-2.1\com.google.appengine\appengine-endpoints\1.9.28\bf2e8a74bd28e388b3487fc78a0c7adfa592fd5d\appengine-endpoints-1.9.28.jar`
Executing tasks: [:app:clean, :app:generateDebugSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:generateDebugAndroidTestSources, :app:assembleDebug]

Configuration on demand is an incubating feature.
WARNING: Dependency org.apache.httpcomponents:httpclient:4.0.1 is ignored for debug as it may be conflicting with the internal version provided by Android.
     In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency org.apache.httpcomponents:httpclient:4.0.1 is ignored for release as it may be conflicting with the internal version provided by Android.
     In case of problem, please repackage it with jarjar to change the class packages
Incremental java compilation is an incubating feature.
:app:clean
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:backend:appengineDownloadSdk
:backend:compileJava
:backend:processResources UP-TO-DATE
:backend:classes
:backend:appengineEndpointsGetClientLibs UP-TO-DATE
:backend:appengineEndpointsExpandClientLibs UP-TO-DATE
:backend:compileEndpointsSrcJava
:backend:processEndpointsSrcResources UP-TO-DATE
:backend:endpointsSrcClasses
:backend:_appengineEndpointsAndroidArtifact UP-TO-DATE
:backend:jar UP-TO-DATE
:app:prepareComAndroidSupportAnimatedVectorDrawable2330Library
:app:prepareComAndroidSupportAppcompatV72330Library
:app:prepareComAndroidSupportSupportV42330Library
:app:prepareComAndroidSupportSupportVectorDrawable2330Library
:app:prepareComGoogleAndroidGmsPlayServicesAuth840Library
:app:prepareComGoogleAndroidGmsPlayServicesBase840Library
:app:prepareComGoogleAndroidGmsPlayServicesBasement840Library
:app:prepareComGoogleAndroidGmsPlayServicesMeasurement840Library
:app:prepareDebugDependencies
:app:compileDebugAidl
:app:compileDebugRenderscript
:app:generateDebugBuildConfig
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets
:app:generateDebugResValues UP-TO-DATE
:app:processDebugGoogleServices
:app:generateDebugResources
:app:mergeDebugResources
:app:processDebugManifest
:app:processDebugResources
:app:generateDebugSources
:app:mockableAndroidJar UP-TO-DATE
:app:preDebugUnitTestBuild UP-TO-DATE
:app:prepareDebugUnitTestDependencies
:app:preDebugAndroidTestBuild UP-TO-DATE
:app:prepareDebugAndroidTestDependencies
:app:compileDebugAndroidTestAidl
:app:processDebugAndroidTestManifest
:app:compileDebugAndroidTestRenderscript
:app:generateDebugAndroidTestBuildConfig
:app:generateDebugAndroidTestAssets UP-TO-DATE
:app:mergeDebugAndroidTestAssets
:app:generateDebugAndroidTestResValues UP-TO-DATE
:app:generateDebugAndroidTestResources
:app:mergeDebugAndroidTestResources
:app:processDebugAndroidTestResources
:app:generateDebugAndroidTestSources
:app:compileDebugJavaWithJavac
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources
:app:buildInfoDebugLoader
:app:transformClassesWithExtractJarsForDebug
:app:transformClassesWithInstantRunVerifierForDebug
:app:transformClassesWithJavaResourcesVerifierForDebug UP-TO-DATE
:app:mergeDebugJniLibFolders
:app:transformNative_libsWithMergeJniLibsForDebug
:app:processDebugJavaRes UP-TO-DATE
:app:transformResourcesWithMergeJavaResForDebug FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException:     com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK com/google/appengine/repackaged/org/apache/commons/codec/language/bm/sep_approx_spanish.txt
File1: C:\Users\USER\.gradle\caches\modules-2\files-2.1\com.google.appengine\appengine-api-1.0-sdk\1.9.28\e92c18272b555027d9ec666e7a89162f10638314\appengine-api-1.0-sdk-1.9.28.jar
File2: C:\Users\USER\.gradle\caches\modules-2\files-2.1\com.google.appengine\appengine-endpoints\1.9.28\bf2e8a74bd28e388b3487fc78a0c7adfa592fd5d\appengine-endpoints-1.9.28.jar


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

BUILD FAILED

Total time: 15.364 secs
dependencies {
  appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.28'
  compile 'com.google.appengine:appengine-endpoints:1.9.28'
  compile 'com.google.appengine:appengine-endpoints-deps:1.9.28'
  compile 'javax.servlet:servlet-api:2.5'
  compile 'com.google.http-client:google-http-client-jackson2:1.20.0'
  compile 'com.google.http-client:google-http-client-gson:1.19.0'
}
appengineSdk 'com.google.appengine:appengine-java-sdk:1.9.28'
compile 'com.google.appengine:appengine-endpoints:1.9.28'
compile 'com.google.appengine:appengine-endpoints-deps:1.9.28'

共有1个答案

高自怡
2023-03-14

要完成@dsh的回答:

在依赖树中有两个jar文件包含名为sep_approx_spanis.txt的相同文件,这是不允许的。

要解决问题,您必须跟踪您的gradle依赖项中哪一个具有两个名为AppEngine-API-1.0-SDK-1.9.28.jarAppEngine-Endpoints-1.9.28.jar的JAR;要做到这一点,你可以打开android Studio的终端控制台,然后输入:

//if ou are on windows
gradlew dependencies

//if you are on unix based os
./gradlew dependencies
{
    exclude "sep_approx_spanish.txt"
}
compile 'com.google.appengine:appengine-endpoints:1.9.28'
compile 'com.google.appengine:appengine-endpoints-deps:1.9.28

如果必须成为

compile 'com.google.appengine:appengine-endpoints:1.9.28'{
        exclude "sep_approx_spanish.txt"
    }
 compile 'com.google.appengine:appengine-endpoints-deps:1.9.28

compile 'com.google.appengine:appengine-endpoints:1.9.28'
compile 'com.google.appengine:appengine-endpoints-deps:1.9.28'{
        exclude "sep_approx_spanish.txt"
    }

通过这种方式,您告诉gradle不要为两个库中的一个考虑该文件,从而避免了APK中的文件重复。

 类似资料:
  • 我正在尝试在Windows 7上使用Cmake构建OpenCV。我选择使用Visual Studio 10编译器。 我收到以下错误: C:/程序文件 (x86)/CMake 2.8/共享/生成 2.8/模块/CMakeCXX 中的生成错误信息:37 (get_filename_component): get_filename_component调用不正确的参数数调用堆栈(最近的调用优先):CMak

  • 你好,我发送了一个Telegram的Github源代码。但当我试图构建apk时,我得到了两种类型的错误--首先是-External Native build Issues,其中包含以下详细信息- 第二个错误指向文件-c:\users\the\appdata\local\android\sdk\ndk-bundle\build\core\prebuild-library.mk,该文件包含此- pre

  • 问题内容: 我正在尝试使用PyInstaller 1.5编译PyQt程序。当我使用– onedir(默认设置)时,以下两个程序对我来说都工作正常,但这会创建相当大的程序。我想使用– onefile选项,但是在运行创建的onefile应用程序时,出现错误消息: 这两个都发生此错误: 和这个: 有人有什么想法吗? 问题答案: 1,Pyinstaller不会创建比–onedir小的–onefile。运行

  • 我想知道是否有人能告诉我为什么当我尝试使用改版执行RESTfull服务时会出现错误请求错误 翻新接口: MainActivity中的Asyntask 结果总是失败。我最初认为问题是因为Reverfit内置的gson转换器在将响应转换为stock对象时遇到了麻烦,因为我只收到了一个“reverfit.retrofiterror”响应。但是“bad request”响应让我认为问题出在API的URL上

  • 我试图建立一个基本的应用程序使用Kotlin/Anko,但我得到以下重复文件例外 我尝试删除gradle缓存并再次构建项目,但没有任何工作。请告诉我哪里出了问题?