条目名称 'META-INF/MANIFEST.MF' 发生冲突

Entry name 'META-INF/MANIFEST.MF' collided

描述

当 运行 detox build -c android

时,我一直收到以下错误
> Task :app:packageDebugAndroidTest FAILED
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:packageDebugAndroidTest'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > Entry name 'META-INF/MANIFEST.MF' collided

复制

我的文件

.detoxrc.json

{
  ...
    "android": {
      "binaryPath": "android/app/build/outputs/apk/debug/app-debug.apk",
      "build": "cd android && ./gradlew app:assembleDebug app:assembleAndroidTest -DtestBuildType=debug && cd ..",
      "type": "android.emulator",
      "device": {
        "avdName": "Pixel_API_28_AOSP"
      }
    }
  ...

android/app.build.gradle

前 3 个选项是解决问题的失败尝试。在尝试安装 Detox 之前,最后一个选项已经存在于项目中。

...
android {
    ...
    packagingOptions {
        // exclude 'META-INF/**'
        // pickFirst 'META-INF/**'
        // merge 'META-INF/**'
        pickFirst "**"
    }
    ...
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    //noinspection GradleDynamicVersion
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
    implementation 'com.facebook.fresco:animated-gif:2.0.0'
    debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
        exclude group:'com.facebook.fbjni'
    }
    debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
        exclude group:'com.facebook.flipper'
        exclude group:'com.squareup.okhttp3', module:'okhttp'
    }
    debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
        exclude group:'com.facebook.flipper'
    }
    addUnimodulesDependencies()

    if (enableHermes) {
        def hermesPath = "../../node_modules/hermes-engine/android/";
        debugImplementation files(hermesPath + "hermes-debug.aar")
        releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
        implementation jscFlavor
    }

    androidTestImplementation('com.wix:detox:+')
    androidTestImplementation(project(path: ":detox"))
}
...

环境

其他可能有用的信息

可能的解决方法是禁用 Gradle 插件 3.6.0-alpha09 中引入的 zipflinger。只需在 gradle.properties android.useNewApkCreator=false

中添加一个新行

Google blog or check a 阅读更多关于旗帜的信息。