运行错误:任务“:app:transformResourcesWithMergeJavaResForDebug”执行失败

Pro*_*ing 5 android gradle android-build build.gradle android-gradle-plugin

任务 \':app:transformResourcesWithMergeJavaResForDebug\'运行错误
执行失败\n因此,我在尝试运行我的项目时不断收到 gradle 构建错误。我搜索过其他解决方案,有些人说添加:

\n\n
packagingOptions {\n    exclude \'META-INF/NOTICE\'\n    exclude \'META-INF/LICENSE\' // will not include LICENSE file\n    // as noted by @Vishnuvathsan you may also need to include\n    // variations on the file name. It depends on your dependencies.\n    // Some other common variations on notice and license file names\n    exclude \'META-INF/notice\'\n    exclude \'META-INF/notice.txt\'\n    exclude \'META-INF/license\'\n    exclude \'META-INF/license.txt\'\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n

但它对我不起作用。错误如下:\n错误:任务\':app:transformResourcesWithMergeJavaResForDebug\'执行失败。

\n\n
\n

com.android.build.api.transform.TransformException:com.android.builder.packaging.DuplicateFileException:在 APK META-INF/rxjava.properties 中复制的重复文件

\n
\n\n
**File1: E:\\Workspace_Android\\TravelStory\\app\\build\\intermediates\\exploded-aar\\cn.bmob.android\\bmob-sdk\\3.5.0\\jars\\classes.jar\nFile2: C:\\Users\\Prometheus\\.gradle\\caches\\modules-2\\files-2.1\\io.reactivex\\rxjava\\1.2.1\\4e4cfa4adc74521d5966799fa5ab70b733552f68\\rxjava-1.2.1.jar**\n
Run Code Online (Sandbox Code Playgroud)\n\n

我尝试删除 File2,但在编译/gradle 后,文件再次创建。
\n studio 版本是 2.2.3
\ngradle 版本是 2.2.3

\n\n

我的gradle文件内容如下:

\n\n
apply plugin: \'com.android.application\'\napply plugin: \'android-apt\'\n\nandroid {\n    compileSdkVersion 25\n    buildToolsVersion "25.0.2"\n    defaultConfig {\n        applicationId "com.example.travelstory.travelstory"\n        minSdkVersion 15\n        targetSdkVersion 25\n        versionCode 1\n        versionName "1.0"\n        multiDexEnabled true;\n    }\n\n    packagingOptions {\n        exclude \'META-INF/NOTICE\'\n        exclude \'META-INF/LICENSE\' // will not include LICENSE file\n        // as noted by @Vishnuvathsan you may also need to include\n        // variations on the file name. It depends on your dependencies.\n        // Some other common variations on notice and license file names\n        exclude \'META-INF/notice\'\n        exclude \'META-INF/notice.txt\'\n        exclude \'META-INF/license\'\n        exclude \'META-INF/license.txt\'\n    }\n\n    buildTypes {\n        release {\n            minifyEnabled false\n            proguardFiles getDefaultProguardFile(\'proguard-android.txt\'), \'proguard-rules.pro\'\n        }\n    }\n    configurations.all {\n        resolutionStrategy.force \'com.google.code.findbugs:jsr305:3.0.1\'\n    }\n}\n\ndependencies {\n    compile fileTree(include: [\'*.jar\'], dir: \'libs\')\n    androidTestCompile(\'com.android.support.test.espresso:espresso-core:2.2.2\', {\n        exclude group: \'com.android.support\', module: \'support-annotations\'\n    })\n    compile \'com.android.support:appcompat-v7:25.1.0\'\n    compile \'com.android.support:design:25.0.1\'\n    compile \'com.android.support:multidex:1.0.1\'\n    //\xe5\xb1\x8f\xe5\xb9\x95\xe8\x87\xaa\xe5\x8a\xa8\xe9\x80\x82\xe9\x85\x8d\n    compile \'com.zhy:autolayout:1.4.5\'\n    //\xe6\xb3\xa8\xe8\xa7\xa3\xe6\xa1\x86\xe6\x9e\xb6\n    compile \'com.jakewharton:butterknife:8.4.0\'\n    apt \'com.jakewharton:butterknife-compiler:8.4.0\'\n    //6.0\xe6\x9d\x83\xe9\x99\x90rx\n    compile \'com.tbruyelle.rxpermissions:rxpermissions:0.9.1@aar\'\n    //RxJava RxLifecycle\xe7\x94\x9f\xe5\x91\xbd\xe5\x91\xa8\xe6\x9c\x9f\xe7\xae\xa1\xe7\x90\x86\n    compile \'com.trello:rxlifecycle:1.0\'\n    compile \'com.trello:rxlifecycle-components:1.0\'\n    //3.5.0\xef\xbc\x9a\xe8\xaf\xb7\xe5\x8a\xa1\xe5\xbf\x85\xe6\x9f\xa5\xe7\x9c\x8b\xe4\xb8\x8b\xe9\x9d\xa2\xe6\xb3\xa8\xe9\x87\x8a[1]\n    compile (\'cn.bmob.android:bmob-sdk:3.5.0\')\n    //            {\n    //        exclude group: \'io.reactivex:rxjava:1.1.6\'\n    //    }\n    //\xe5\xa6\x82\xe6\x9e\x9c\xe4\xbd\xa0\xe6\x83\xb3\xe5\xba\x94\xe7\x94\xa8\xe8\x83\xbd\xe5\xa4\x9f\xe5\x85\xbc\xe5\xae\xb9Android6.0\xef\xbc\x8c\xe8\xaf\xb7\xe6\xb7\xbb\xe5\x8a\xa0\xe6\xad\xa4\xe4\xbe\x9d\xe8\xb5\x96(org.apache.http.legacy.jar)\n    compile \'cn.bmob.android:http-legacy:1.0\'\n    //bmob-push\xef\xbc\x9aBmob\xe7\x9a\x84\xe6\x8e\xa8\xe9\x80\x81\xe5\x8c\x85\n    compile \'cn.bmob.android:bmob-push:0.8\'\n    //\xe5\xa4\x9afragment\xe5\xa4\x9a\xe6\xa8\xa1\xe5\x9d\x97Activity\n    compile \'me.yokeyword:fragmentation:0.9.3\'\n    // \xe5\xa6\x82\xe6\x9e\x9c\xe6\x83\xb3\xe4\xbd\xbf\xe7\x94\xa8SwipeBack \xe6\xbb\x91\xe5\x8a\xa8\xe8\xbe\xb9\xe7\xbc\x98\xe9\x80\x80\xe5\x87\xbaFragment/Activity\xe5\x8a\x9f\xe8\x83\xbd\xef\xbc\x8c\xe8\xaf\xb7\xe5\x86\x8d\xe6\xb7\xbb\xe5\x8a\xa0\xe4\xb8\x8b\xe9\x9d\xa2\xe7\x9a\x84\xe5\xba\x93\n    compile \'me.yokeyword:fragmentation-swipeback:0.7.9\'\n}\n
Run Code Online (Sandbox Code Playgroud)\n

JBi*_*gas 4

您不排除错误警告的文件。

com.android.build.api.transform.TransformException:com.android.builder.packaging.DuplicateFileException:在 APK META-INF/rxjava.properties 中复制的重复文件

这里的抱怨是META-INF/rxjava.properties,只需更新您的packageOptions块以明确排除此文件即可。

packagingOptions {
    exclude 'META-INF/rxjava.properties'
    // ... and any other excludes go here
}
Run Code Online (Sandbox Code Playgroud)