Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

android - How to resolve Duplicate files copied in APK META-INF/rxjava.properties

I am using rxjava and rxvolley on my android aplication. When I try to run it I get this error

Execution failed for task ':testapp:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/rxjava.properties
            File1: C:UsersDaniel.gradlecachesmodules-2files-2.1io.reactivex
xjava1.1.0748f0546d5c3c27f1aef07270ffea0c45f0c42a4
xjava-1.1.0.jar
            File2: C:UsersDaniel.gradlecachesmodules-2files-2.1io.reactivex.rxjava2
xjava2.0.3d2f725668bd22e21170381b23f8fbdf72c69d886
xjava-2.0.3.jar

I have a exclude.gradle file like this

android {
packagingOptions {
    exclude 'META-INF/DEPENDENCIES.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/rxjava.properties'
    exclude 'META-INF/rxjava.PROPERTIES'
    exclude 'META-INF/RXJAVA.properties'
    exclude 'META-INF/RXJAVA.PROPERTIES'
    exclude 'META-INF/rxjava'
    exclude 'META-INF/RXJAVA'
}

lintOptions {
    abortOnError false
}
}

How can I fix this problem?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I had the same problem. The way I fixed it is adding the packagingOptions in app gradle as described in Duplicated file rxjava.properties

android {

    defaultConfig {
    }
    buildTypes {
    }
    packagingOptions{
        exclude 'META-INF/rxjava.properties'
    }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...