gpt4 book ai didi

Android - 任务 :app:mergeDexRelease FAILED

转载 作者:行者123 更新时间:2023-12-03 03:01:12 29 4
gpt4 key购买 nike

请考虑我对Android开发不是很熟悉。
尝试为我的 React Native 应用程序生成 Android 签名包时,我偶然发现了以下错误:

Task :app:mergeDexRelease FAILED
D8: Program type already present: com.horcrux.svg.Brush$BrushType
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
Learn how to resolve the issue at
https://developer.android.com/studio/build/dependencies#duplicate_classes.
Program type already present: com.horcrux.svg.Brush$BrushType

...

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDexRelease'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Program type already present: com.horcrux.svg.Brush$BrushType
  • 我知道 BrushType是来自 react-native-svg 的类
  • 我跑了gradlew app:dependencies并没有找到依赖于 Brush 的模块或与 com.horcrux.svg 相关的任何内容或 react-native-svg
  • 已经尝试清理项目,删除.iml文件,使 Android Studio 缓存失效,重建,重新安装 node_modules等等
  • 试图弄乱 build.gradlegradle.properties没有运气
  • 我已通读 this android guide on duplicate classes也没有运气

  • 我了解有 2 个或更多依赖项使用 com.horcrux.svg.Brush$BrushType但我找不到他们。我想一旦我找到它们,我就可以做到
    implementation(:my-library) {
    exclude ...
    }
    正确的?
    gradle.properties
    android.useAndroidX=true
    android.enableJetifier=true

    org.gradle.daemon=true
    org.gradle.jvmargs=-Xmx2560m
    android/app/build.gradle
    dependencies {
    implementation project(':react-native-appearance')
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.facebook.react:react-native:+" // From node_modules
    implementation project(':watermelondb')
    implementation project(':react-native-calendar-events')

    if (enableHermes) {
    def hermesPath = "../../node_modules/hermes-engine/android/";
    debugImplementation files(hermesPath + "hermes-debug.aar")
    releaseImplementation files(hermesPath + "hermes-release.aar")
    } else {
    implementation jscFlavor
    }
    }
    提前致谢。
    编辑:
    通过添加解决:
        implementation(project(':react-native-jitsi-meet')) {
    ...
    exclude group: 'com.facebook.react',module:'react-native-svg'
    ...
    }
    就我而言,它是 react-native-jitsi-meet这导致了冲突,我不得不通过反复试验找到它。

    最佳答案

    defaultConfig {
    ..............
    multiDexEnabled true
    }

    dependencies {
    ..............
    implementation 'androidx.multidex:multidex:2.0.1'
    }

    public class MyApplication extends MultiDexApplication {
    ..............
    }

    关于Android - 任务 :app:mergeDexRelease FAILED,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61067571/

    29 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com