Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'. > com.android.bui
2017-10-12 16:43
686 查看
下午好,今天来看看我遇到的一个问题(错误如下):
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'. > com.android.bui
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:\Users\pc\.gradle\daemon\gradle-2.8\wrapper\dists\gradle-3.3-all\caches\modules-2\files-2.1\io.reactivex\rxjava\1.1.5\ece7b5d0870e66d8226dab6dcf47a2b12afff061\rxjava-1.1.5.jar File2: C:\Users\pc\.gradle\daemon\gradle-2.8\wrapper\dists\gradle-3.3-all\caches\modules-2\files-2.1\io.reactivex.rxjava2\rxjava\2.0.7\21734c0092a5d3c3ec99510e50c1ff76bdf0c65a\rxjava-2.0.7.jar
这是一个关于rxjava包冲突的错误,也就是说,我们导入了两个不同版本的rxjava的包而导致的,IDE可能是无法自己选择某一个从而导致的一个冲突,废话不多说,直接看看怎么解决:
android { compileSdkVersion rootProject.ext.android["compileSdkVersion"] buildToolsVersion rootProject.ext.android["buildToolsVersion"] useLibrary 'org.apache.http.legacy' compileOptions { targetCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8 } defaultConfig { applicationId "me.jessyan.mvparms.demo" minSdkVersion rootProject.ext.android["minSdkVersion"] targetSdkVersion rootProject.ext.android["targetSdkVersion"] versionCode rootProject.ext.android["versionCode"] versionName rootProject.ext.android["versionName"] testInstrumentationRunner rootProject.ext.dependencies["androidJUnitRunner"] } buildTypes { debug { buildConfigField "boolean", "LOG_DEBUG", "true" buildConfigField "boolean", "USE_CANARY", "true" minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } release { buildConfigField "boolean", "LOG_DEBUG", "false" buildConfigField "boolean", "USE_CANARY", "false" minifyEnabled true shrinkResources true zipAlignEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } packagingOptions{ exclude 'META-INF/rxjava.properties' exclude 'META-INF/NOTICE' // will not include NOTICE file exclude 'META-INF/LICENSE' // will not include LICENSE file // as noted by @Vishnuvathsan you may also need to include // variations on the file name. It depends on your dependencies. // Some other common variations on notice and license file names exclude 'META-INF/notice' exclude 'META-INF/notice.txt' exclude 'META-INF/license' exclude 'META-INF/license.txt' } lintOptions { disable 'InvalidPackage' disable "ResourceType" abortOnError false } } buildscript { repositories { jcenter() } } dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') //support compile(rootProject.ext.dependencies["cardview-v7"]) { exclude module: 'support-annotations' } //tools annotationProcessor rootProject.ext.dependencies["dagger2-compiler"] compile rootProject.ext.dependencies["progressmanager"] compile rootProject.ext.dependencies["retrofit-url-manager"] provided rootProject.ext.dependencies["javax.annotation"]//dagger2必须依赖jsr250 annotation //view annotationProcessor(rootProject.ext.dependencies["butterknife-compiler"]) { exclude module: 'support-annotations' exclude module: 'butterknife-annotations' } compile rootProject.ext.dependencies["paginate"] //arms compile project(':arms') // compile 'me.jessyan:arms:2.2.3' //test testCompile rootProject.ext.dependencies["junit"] debugCompile rootProject.ext.dependencies["canary-debug"] releaseCompile rootProject.ext.dependencies["canary-release"] testCompile rootProject.ext.dependencies["canary-release"] compile 'com.android.support.constraint:constraint-layout:1.0.2' compile 'com.android.support:recyclerview-v7:26.0.0-alpha1' compile 'com.google.code.gson:gson:2.3' compile 'com.squareup.retrofit:retrofit:2.0.0-beta1' compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2' compile 'com.squareup.okhttp:okhttp:2.4.0' compile 'com.squareup.retrofit:retrofit:2.0.0-beta2' compile 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta2' // compile 'io.reactivex:rxjava:1.1.0' compile 'io.reactivex:rxandroid:1.1.0' compile 'com.squareup.retrofit2:adapter-rxjava:2.0.2' compile 'com.squareup.retrofit2:converter-scalars:2.1.0' compile 'com.squareup.retrofit2:retrofit:2.1.0' compile 'com.squareup.retrofit2:converter-gson:2.1.0' }
上面是我的build.gradle文件,大家可以看看添加的代码放在什么位置,下面是我所添加的代码,来看看吧:
packagingOptions{ exclude 'META-INF/rxjava.properties' exclude 'META-INF/NOTICE' // will not include NOTICE file exclude 'META-INF/LICENSE' // will not include LICENSE file // as noted by @Vishnuvathsan you may also need to include // variations on the file name. It depends on your dependencies. // Some other common variations on notice and license file names exclude 'META-INF/notice' exclude 'META-INF/notice.txt' exclude 'META-INF/license' exclude 'META-INF/license.txt' }
我的错误是导入了两个rxjava的不同版本的包导致的,因为IDE好像无法从两个包里去选择一个来用,从而导致了依赖包的冲突,所以除了rxjava的冲突还有可能在我们导依赖包的时候出现其他的包的冲突,这都要在packagingOptions里添加对应的过滤,添加这句是用来滤文件配置的,我的错误解决是添加下面一句rxjava的过滤代码:
exclude 'META-INF/rxjava.properties'
OK,再也不用担心重新来过啦,希望对大家有所帮助,谢谢!
相关文章推荐
- Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'. > com.android.bui
- Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'. > com.android.bui
- Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'. > com.android.bui
- Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'. > com.android.bui
- Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'. > com.android.bui
- Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForUmengDebug'. > com.androi
- 我的Android进阶之旅------>解决:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
- 我的Android进阶之旅------>解决:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
- 解决Error:Execution failed for task ':show_entry:transformResourcesWithMergeJavaResForDebug'. > com.an
- 我的Android进阶之旅------>解决:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
- Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'. > More than one f
- 我的Android进阶之旅------>解决:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
- Android--Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
- Gradle build error, Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug
- Android Studio 运行出现 Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug
- Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
- Gradle build error, Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug
- Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.解决方法
- Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
- Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.