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

标签 android react-native build.gradle detox

描述
我在运行 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
复制
  • 执行步骤 here为 android 设置 detox(没有测试管家步骤)
  • 按照描述设置以下 2 个文件(减去我的依赖项)
  • 运行detox build -c android (无论是否先构建了 aosp 模拟器)

  • 我的文件.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"))
    }
    ...
    
    环境
  • 排毒:^17.14.3
  • react 原生:0.63.2
  • com.android.tools.build:gradle: 4.0.1
  • 节点:v12.19.0
  • 设备:Android AOSP 像素模拟器 API 28
  • 操作系统:MacOS Catalina v10.15.7
  • 测试运行者:jest

  • 其他可能有用的信息
  • Detox 可以为 iOS 构建和运行测试,但不适用于 android
  • 使用 --stacktrace 运行构建命令没有提供任何进一步的信息
  • 这是我第一次尝试在这个项目上设置排毒
  • detox docs 中列出的解决方案还没修复
  • 我发现很多关于线程相关错误的东西(尽管没有提到排毒)与 gradle 版本有关。很多人建议降级。
  • 我可以通过 android studio 使用 build 命令在普通的 Pixel 模拟器和 AOSP 上构建实际的应用程序。此问题仅在尝试通过 detox-cli 使用构建命令时出现。
  • 最佳答案

    可能的解决方法是禁用 Gradle Plugin 3.6.0-alpha09 中引入的 zipflinger。只需在 gradle.properties android.useNewApkCreator=false 中添加新行
    Google blog 上阅读有关该标志的更多信息或查看 similar issue .

    关于android - 条目名称 'META-INF/MANIFEST.MF' 发生冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65676024/

    相关文章:

    android - 如何在运行时生成 ImageView

    javascript - React/Redux 传递状态变化 <Picker>

    spring-boot - IntelliJ Gradle同步错误

    android - 如何使用更新版本的 gradle 构建 Android 项目?

    Android 构建发布失败,原因为 : java. lang.ArrayIndexOutOfBoundsException: 213(pr​​oguard 问题)

    android - 如何判断经纬度是否准确

    android - React native 生成​​ ProGuard 映射文件

    android - SQLite 数据库未显示在文件资源管理器中

    javascript - 如何防止图像在 react native 中的 uri 重新加载时闪烁?

    javascript - react 导航错误 : The navigation prop is missing for this navigator