ammarahm-ed / react-native-mmkv-storage

An ultra fast (0.0002s read/write), small & encrypted mobile key-value storage framework for React Native written in C++ using JSI
https://rnmmkv.now.sh
MIT License
1.56k stars 109 forks source link

Detox android test failed #321

Closed Vick04 closed 11 months ago

Vick04 commented 1 year ago

Describe the bug I have the following error when I try to run Detox tests on android.

`* What went wrong: Execution failed for task ':react-native-mmkv-storage:mergeDebugAndroidTestNativeLibs'.

A failure occurred while executing com.android.build.gradle.internal.tasks.MergeNativeLibsTask$MergeNativeLibsTaskWorkAction 2 files found with path 'lib/arm64-v8a/libc++_shared.so' from inputs:

  • /MY_PROJECT/node_modules/react-native-mmkv-storage/android/build/intermediates/library_jni/debug/jni/arm64-v8a/libc++_shared.so
  • /home/jmzp/.gradle/caches/transforms-3/c22b30f4dea7b051abf86a530555f13b/transformed/jetified-react-android-0.71.4-debug/jni/arm64-v8a/libc++_shared.so If you are using jniLibs and CMake IMPORTED targets, see https://developer.android.com/r/tools/jniLibs-vs-imported-targets`

To Reproduce Steps to reproduce the behavior:

  1. Migrate a RN project 0.66.5 to 0.71.4
  2. Install Detox following the official documentation
  3. Run detox build --configuration android.emu.debug

Platform Information:

Additional context I was able to fix it by creating this patch:

diff --git a/node_modules/react-native-mmkv-storage/android/build.gradle b/node_modules/react-native-mmkv-storage/android/build.gradle
index 7b6e1b1..cb45fe4 100644
--- a/node_modules/react-native-mmkv-storage/android/build.gradle
+++ b/node_modules/react-native-mmkv-storage/android/build.gradle
@@ -36,6 +36,13 @@ repositories {
 android {
   compileSdkVersion safeExtGet("compileSdkVersion", 31)

+  packagingOptions {
+    pickFirst 'lib/x86/libc++_shared.so'
+    pickFirst 'lib/x86_64/libc++_shared.so'
+    pickFirst 'lib/arm64-v8a/libc++_shared.so'
+    pickFirst 'lib/armeabi-v7a/libc++_shared.so'
+  }
+
   buildFeatures {
     prefab true
   }

I hope this will be useful for the next update.

Greets!