RxJava1.X和RxJava2.X同时使用冲突问题

2018-05-18  本文已影响25人  神一般的男子

前言:最近在反编译一个apk项目,发现这个项目当中同时用到RxJava1.X和RxJava2.X,编译一直冲突报错

报错如下:

Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.

> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/rxjava.properties

如图所示:

谷歌找了一下资料提示要删除  rxjava.properties//删除META-INF信息

复制下面内容在app目录下的build.gradle   android {}里面,重新编译就可以了。

//删除META-INF信息

packagingOptions {

exclude 'META-INF/rxjava.properties'

exclude 'META-INF/maven/com.squareup.okhttp3/okhttp/pom.xml'

exclude 'META-INF/maven/com.squareup.okhttp3/okhttp/pom.properties'

exclude 'META-INF/maven/com.squareup.okio/okio/pom.xml'

exclude 'META-INF/maven/com.squareup.okio/okio/pom.properties'

exclude 'META-INF/maven/com.google.code.gson/gson/pom.xml'

exclude 'META-INF/maven/com.google.code.gson/gson/pom.properties'

exclude 'META-INF/DEPENDENCIES.txt'

exclude 'META-INF/NOTICE' exclude 'META-INF/NOTICE.txt'

exclude 'META-INF/LICENSE' exclude 'META-INF/LICENSE.txt'

}


这样项目就可以同时使用RxJava1.X和RxJava2.X不同的api

上一篇下一篇

猜你喜欢

热点阅读