Android-任务:app:mergeDexRelease失败 gradle.properties android / app / build.gradle

请考虑我对Android开发不是很熟悉。

尝试为我的React Native应用生成Android签名的捆绑包时,我偶然发现了以下错误:

CompanyName
  • 我知道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或与Brushcom.horcrux.svg相关的任何内容
  • 已经尝试清理项目,删除react-native-svg文件,使Android Studio缓存无效,重建,重新安装.iml
  • 尝试与node_modulesbuild.gradle混在一起,没有运气
  • 我也没有碰过this android guide on duplicate classes

我知道利用gradle.properties有2个或更多的依赖项,但是我找不到它们。我想一旦找到它们,我就能做到

com.horcrux.svg.Brush$BrushType

正确吗?

gradle.properties

implementation(:my-library) {
  exclude ...
}

android / app / build.gradle

android.useAndroidX=true
android.enableJetifier=true

org.gradle.daemon=true
org.gradle.jvmargs=-Xmx2560m

谢谢。

编辑:

添加以下内容即可解决:

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' ... } 导致了冲突,我不得不通过反复试验来找到它。

henshui22 回答:Android-任务:app:mergeDexRelease失败 gradle.properties android / app / build.gradle

[
  {
    "$unwind": {
      path: "$items"
    }
  },{
    "$sort": {
      "items.value": -1
    }
  },{
    "$group": {
      "_id": "$_id","name": {
        "$first": "$name"
      },topValue: {
        $first: "$items.value"
      },"items": {
        "$push": "$items"
      }
    }
  },{
    "$sort": {
      "topValue": -1
    }
  },{
    "$project": {
      topValue: 0
    }
  }
]
本文链接:https://www.f2er.com/2498794.html

大家都在问