如下所示,编译时报错:
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 File1: C:Userslhw.gradlecachesmodules-2files-2.1io.reactivex.rxjava2 xjava2.0.157f850a6b317e5582f1dbaff10a9e7d7e1fcdcfb xjava-2.0.1.jar File2: C:Userslhw.gradlecachesmodules-2files-2.1io.reactivex xjava1.2.042bfaf64c94f3848ebf5cf1c2ea4ec9d1b3ac6c8 xjava-1.2.0.jar
解决方法:
报错原因是因为依赖错误:
修改如下:
compile 'com.squareup.retrofit2:retrofit:2.2.0' //compile 'com.squareup.retrofit2:adapter-rxjava:1.0.0' compile 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0' compile 'com.squareup.retrofit2:converter-gson:2.2.0'
修改依赖后注意修改一下代码: