Getting 'app:transformClassesWithDexForDebug' error on compiling the project having useLibrary 'org.apache.http.legacy' in build.gradle

前端 未结 5 1794
悲&欢浪女
悲&欢浪女 2021-01-18 11:40

I\'m developing an app in which I\'m using this library.

On compiling the project, this error containing TransformException and RuntimeException<

5条回答
  •  暖寄归人
    2021-01-18 12:04

    From the log:

    Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
    > com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK log4j.properties
        File1: C:\Users\user\.gradle\caches\modules-2\files-2.1\org.brunocvcunha.inutils4j\inutils4j\0.4\566b82b1e70d7ebb8d1d3bb513d4bbf7913b118b\inutils4j-0.4.jar
        File2: C:\Users\user\.gradle\caches\modules-2\files-2.1\org.brunocvcunha.ghostme4j\ghostme4j\0.2\d44c3633f23975c355c89192d6e8daa9ce549b2d\ghostme4j-0.2.jar
    

    It looks like you need to exclude log4j.properties from your project because it reside in both of the libraries (inutils4j and ghostme4j). You can try using:

    android {
    ...
        packagingOptions {
             exclude '**/log4j.properties'
        }
    ...
    }
    

    Read more about PackagingOptions.

提交回复
热议问题