react-native-safe-area-context icon indicating copy to clipboard operation
react-native-safe-area-context copied to clipboard

RNCSafeAreaProviderManagerDelegate

Open nguyenhuynhdeveloper opened this issue 5 months ago • 3 comments

Description

  • What went wrong: Execution failed for task ':app:mergeDexRelease'.

A failure occurred while executing com.android.build.gradle.internal.tasks.DexMergingTaskDelegate There was a failure while executing work items > A failure occurred while executing com.android.build.gradle.internal.tasks.DexMergingWorkAction > com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: Type com.facebook.react.viewmanagers.RNCSafeAreaProviderManagerDelegate is defined multiple times: ........./android/build/react-native-safe-area-context/.transforms/5881264dd4d599dc960493152bcf525f/transformed/bundleLibRuntimeToDirRelease/bundleLibRuntimeToDirRelease_dex/com/facebook/react/viewmanagers/RNCSafeAreaProviderManagerDelegate.dex, ........../android/build/app/intermediates/external_libs_dex/release/mergeExtDexRelease/classes3.dex Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.

Steps to reproduce

RNCSafeAreaProviderManagerDelegate

Snack or a link to a repository

RNCSafeAreaProviderManagerDelegate

Safe Area Context version

4.10.8

React Native version

0.73.8

Platforms

Android

Architecture

Paper (Old Architecture)

Build type

Release mode

Device

Android emulator

Device model

No response

Acknowledgements

Yes

nguyenhuynhdeveloper avatar Aug 14 '25 12:08 nguyenhuynhdeveloper

Any workarounds to solve this issue?

htutwaiphyoe avatar Oct 05 '25 09:10 htutwaiphyoe

I removed

react-native-safe-area-context

From my package.json

yfuks avatar Oct 07 '25 09:10 yfuks

Removing the lib from my package.json only created another issue: @react-navigation/* needs it at some point and then the app crashes in runtime, when loading the bundle. My solution was to keep the dependencies and adding the following to the app/android/build.gradle setup:


android {

  sourceSets {
      main {
        manifest.srcFile "src/main/AndroidManifestNew.xml"
        // Exclude safe-area-context, screens, and gesture-handler codegen files to avoid duplicates
        java {
          exclude '**/com/facebook/react/viewmanagers/*SafeArea*'
          exclude '**/com/facebook/react/viewmanagers/*Screen*'
          exclude '**/com/facebook/react/viewmanagers/RNS*'
          exclude '**/com/facebook/react/viewmanagers/RNGesture*'
          exclude '**/com/facebook/fbreact/specs/*SafeArea*'
          exclude '**/com/facebook/fbreact/specs/*Screen*'
          exclude '**/com/facebook/fbreact/specs/*Gesture*'
        }
      }
    }

   // ...other stuff 
}

spent almost a week on this one, brilliant!

JGeraldoLima avatar Oct 13 '25 15:10 JGeraldoLima