mrousavy / react-native-mmkv

โšก๏ธ The fastest key/value storage for React Native. ~30x faster than AsyncStorage!
https://mrousavy.com
MIT License
6.29k stars 259 forks source link

Build Error on React Native 0.71.0 #497

Closed hamdij0maa closed 1 year ago

hamdij0maa commented 1 year ago

**/node_modules/react-native-mmkv/android/build.gradle' line: 173

tobua commented 1 year ago

Pull request with the necessary changes seems to be ready already but not yet merged: #480 (0.71 has just been released a couple of hours ago).

retyui commented 1 year ago

you can use an early version from git

yarn add mrousavy/react-native-mmkv#feat/migrate-rn-71

Require to enable newArchEnabled=true in android/gradle.properties file

hamdij0maa commented 1 year ago

๐Ÿ‘Ž๐Ÿผfor Fabric yes, but our need is using RN 0.71.X without Fabric

retyui commented 1 year ago

๐Ÿ‘Ž๐Ÿผfor Fabric yes, but our need is using RN 0.71.X without Fabric

Why you can't use the Fabric?

hamdij0maa commented 1 year ago

๐Ÿ‘Ž๐Ÿผfor Fabric yes, but our need is using RN 0.71.X without Fabric

Why you can't use the Fabric?

because am using other libs that do not support fabric yet

chrisbianca commented 1 year ago

I would also echo the need to continue support for the old architecture. There are a number of react native libraries that can't be updated to the new architecture whilst it does not support static frameworks, e.g. react-native-firebase

hamdij0maa commented 1 year ago

@mrousavy please do you confirm that the upcoming release will work without enabling Fabric ? or it will only work with Fabric enabled ?

tobua commented 1 year ago

@hamdij0maa according to this note in the pull request it will only work on 0.71 with fabric enabled:

โš ๏ธ Note: This is a breaking change. react-native-mmkv now only builds on RN 0.71 and above using the new architecture. For the sake of simplicity, it is not backwards compatible.

Meaning if you cannot enable fabric you'll have to stay on 0.70.6. Fabric is now the default architecture for RN, so this breaking change makes sense.

hamdij0maa commented 1 year ago

It's not the default :v Fabric renderer is not enabled by default, and most of libs example @FlashList by shopify does not support fabric renderer yet :v

hamdij0maa commented 1 year ago

@mrousavy even enabling fabric I have the same error : FAILURE: Build failed with an exception.

tobua commented 1 year ago

@hamdij0maa You got a point, didn't know it wasn't already enabled by default.

hamdij0maa commented 1 year ago

@hamdij0maa You got a point, didn't know it wasn't already enabled by default.

No prob brother, we just trying to get it working for all xD hopefully @mrousavy publish the needed changes soon ๐Ÿคฃ

Titozzz commented 1 year ago

I think y'all missread This is a breaking change. react-native-mmkv now only builds on RN 0.71 and above using the new architecture. For the sake of simplicity, it is not backwards compatible.

If you are on new arch, you'll need 0.71, otherwise you should still be fine. It's just saying that new arch won't work on 0.68, 0.69 and 0.70.

hamdij0maa commented 1 year ago

Yes, just confirming ๐Ÿ˜‚

leonardoballand commented 1 year ago

Same issue here

RN 0.71 without new architecture :(

ugurdalkiran commented 1 year ago

When is the new version released?

meftunca commented 1 year ago

Please update during the day.

hamdij0maa commented 1 year ago

@mrousavy Please any news regarding the fix ?

ugurdalkiran commented 1 year ago

@mrousavy I need this library in current version (0.71.0). Please I am waiting for an update.

mrousavy commented 1 year ago

These tags are insanely annoying, stop spamming or I ban you from using RN MMKV.

I am running a company and I am currently busy with a few company related things, I will continue to work on an open-source project I made for free (and none of you guys here are paying me for that) when I have some free time.

I expect this to happen later today.

mrousavy commented 1 year ago

@Titozzz is helping me with the RN 0.71 release. We're working on it (https://github.com/mrousavy/react-native-mmkv/pull/480). It's not as easy as it looks, so be patient. Thanks @Titozzz โค๏ธ

mrousavy commented 1 year ago

Just published 2.6.0, this should work on RN 0.71 with new and old architecture! ๐Ÿš€ Thanks for your help @Titozzz โค๏ธ

hamdij0maa commented 1 year ago

thank you for the update, am getting this error Task :app:mergeLibDexDebug FAILED

Task :react-native-mmkv:buildCMakeDebug[x86] C/C++: ninja: Entering directory `/Users//Desktop/apps//node_modules/react-native-mmkv/android/.cxx/Debug/71605c37/x86' @Titozzz do you have an idea how to make it working please?

tobua commented 1 year ago

Working fine for me, thanks!

ugurdalkiran commented 1 year ago

Thank you very much for the update.

But I am getting an error.

Something is conflicting with the react-native-svg library I understand. :/

image

Type com.facebook.react.viewmanagers.RNSVGCircleManagerDelegate is defined multiple times: C:\a071a\node_modules\react-native-mmkv\android\build\.transforms\8397d2fe439e7a0cd7a94dd5881d0a19\transformed\classes\classes.dex, C:\a071a\node_modules\react-native-svg\android\build\.transforms\e4553b6d9bb03a5dcd7595790fe41e48\transformed\classes\classes.dex

hamdij0maa commented 1 year ago

Thank you very much for the update.

But I am getting an error.

Something is conflicting with the react-native-svg library I understand. :/ ...

same error

mikalaiulasevich commented 1 year ago

same with Type com.facebook.react.viewmanagers.RNGestureHandlerButtonManagerDelegate is defined multiple times: /node_modules/react-native-gesture-handler/android/build/.transforms/9016f10b3bbc73680278818232d909ac/transformed/debug/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerDelegate.dex, /node_modules/react-native-mmkv/android/build/.transforms/05fe2efb67e79eed93a93868192077d9/transformed/debug/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerDelegate.dex

mrousavy commented 1 year ago

Did you nuke your gradle cache? https://stackoverflow.com/a/30450020/5281431

mrousavy commented 1 year ago

same with Type com.facebook.react.viewmanagers.RNGestureHandlerButtonManagerDelegate is defined multiple times: /node_modules/react-native-gesture-handler/android/build/.transforms/9016f10b3bbc73680278818232d909ac/transformed/debug/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerDelegate.dex, /node_modules/react-native-mmkv/android/build/.transforms/05fe2efb67e79eed93a93868192077d9/transformed/debug/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerDelegate.dex

That looks like a react-native-gesture-handler error...

ugurdalkiran commented 1 year ago

Did you nuke your gradle cache? https://stackoverflow.com/a/30450020/5281431

Even though I did a gradlew clean, still the same problem. :(

abgaryanharutyun commented 1 year ago

Same here, I cleared all caches and am using the latest version of react-native-mmkv After upgrading, the error changed. I tested building my app without react-native-mmkv and it works well, but when I add it back, I encounter the same issue.

gemcoder21 commented 1 year ago

I'm also getting an error app:mergeLibDexDebug, he is an output from the console:

> Task :react-native-mmkv:configureCMakeDebug[arm64-v8a]
C/C++: CMake Warning at /Users/user/Library/Android/sdk/ndk/23.1.7779620/build/cmake/android-legacy.toolchain.cmake:416 (message):
C/C++:   An old version of CMake is being used that cannot automatically detect
C/C++:   compiler attributes.  Compiler identification is being bypassed.  Some
C/C++:   values may be wrong or missing.  Update to CMake 3.19 or newer to use
C/C++:   CMake's built-in compiler identification.
C/C++: Call Stack (most recent call first):
C/C++:   /Users/user/Library/Android/sdk/ndk/23.1.7779620/build/cmake/android.toolchain.cmake:55 (include)
C/C++:   .cxx/Debug/6r5g1950/arm64-v8a/CMakeFiles/3.18.1-g262b901/CMakeSystem.cmake:6 (include)
C/C++:   CMakeLists.txt:1 (project)

> Task :app:mergeLibDexDebug FAILED

> Task :react-native-mmkv:buildCMakeDebug[arm64-v8a]

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.5.1/userguide/command_line_interface.html#sec:command_line_warnings
182 actionable tasks: 4 executed, 178 up-to-date
error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
ERROR:/app/node_modules/react-native-mmkv/android/build/.transforms/3f9c1da8ef9e9dd791ea35eabfde5b34/transformed/classes/classes.dex: D8: Type com.facebook.react.viewmanagers.RNCSafeAreaProviderManagerDelegate is defined multiple times: /app/node_modules/react-native-mmkv/android/build/.transforms/3f9c1da8ef9e9dd791ea35eabfde5b34/transformed/classes/classes.dex, /app/node_modules/react-native-safe-area-context/android/build/.transforms/c6786e6fef212d007103008b90ae9725/transformed/classes/classes.dex
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: 
Type com.facebook.react.viewmanagers.RNCSafeAreaProviderManagerDelegate is defined multiple times: /app/node_modules/react-native-mmkv/android/build/.transforms/3f9c1da8ef9e9dd791ea35eabfde5b34/transformed/classes/classes.dex, /app/node_modules/react-native-safe-area-context/android/build/.transforms/c6786e6fef212d007103008b90ae9725/transformed/classes/classes.dex
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
    at com.android.builder.dexing.D8DexArchiveMerger.getExceptionToRethrow(D8DexArchiveMerger.java:151)
    at com.android.builder.dexing.D8DexArchiveMerger.mergeDexArchives(D8DexArchiveMerger.java:138)
    at com.android.build.gradle.internal.tasks.DexMergingWorkAction.merge(DexMergingTask.kt:859)
inssein commented 1 year ago

I get the same error as @mikalaiulasevich:

Type com.facebook.react.viewmanagers.RNGestureHandlerButtonManagerDelegate is defined multiple times: /Users/inssein/projects/dittoed/app/node_modules/react-native-gesture-handler/android/build/.transforms/d613df52358496bff3ffec7f5dc6fdeb/transformed/debug/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerDelegate.dex, /Users/inssein/projects/dittoed/app/node_modules/react-native-mmkv/android/build/.transforms/2eb4a9494d7d6ffad6931f884f14eca1/transformed/debug/com/facebook/react/viewmanagers/RNGestureHandlerButtonManagerDelegate.dex

Edit: Don't think its a problem with react native gesture handler. For some reason, when this library builds, it has a lot of viewmanagers compiled that aren't from this library.

inssein commented 1 year ago

@mrousavy looks like the issue was with the build.gradle. I'm pretty new to this, but I just happened to look at the build.gradle of other libraries and caught the fact that other libraries were only doing apply plugin: 'com.facebook.react' if
isNewArchitectureEnabled, like so:

if (isNewArchitectureEnabled()) {
    apply plugin: 'com.facebook.react'
}

I can open a PR if that's correct.

Edit: PR: https://github.com/mrousavy/react-native-mmkv/pull/499. Feel free to close if not relevant.

ugurdalkiran commented 1 year ago

Very interesting.

Although newArchEnabled=false in android/gradle.properties it was always going into this if. ๐Ÿค”

apply plugin: 'com.facebook.react' I completely deleted this and it works, amazing. Thanks @inssein ๐Ÿฅณ

leonardoballand commented 1 year ago

Works like a charm! ๐Ÿ’Ÿ

mrousavy commented 1 year ago

Thanks for your PR @inssein - it's weird that I didn't have this error while testing - which other libraries also do the same approach?

inssein commented 1 year ago

Thanks for dealing with that so quickly @mrousavy. As for your question, I looked at https://github.com/software-mansion/react-native-gesture-handler/blob/main/android/build.gradle#L60 and https://github.com/software-mansion/react-native-svg/blob/main/android/build.gradle#L27

98rahul commented 1 year ago

FAILURE: Build failed with an exception. A problem occurred configuring project ':react-native-mmkv'.

org.gradle.api.InvalidUserDataException: NDK is not installed

[CXX1101] NDK at C:\Users\Your\AppData\Local\Android\Sdk\ndk\23.1.7779620 did not have a source.properties file

build failed as ndk already installed

RN-0.71.1 "react-native-mmkv": "^2.6.1", newArchEnabled=false in android/gradle.properties

@inssein what are the changes need to do... cheers-:)resolved

Victorvikson1996 commented 1 year ago

Configure project :react-native-mmkv [CXX1101] NDK at /Users/chukwuebuka/Library/Android/sdk/ndk/24.0.8215888 did not have a source.properties file [CXX1101] NDK at /Users/chukwuebuka/Library/Android/sdk/ndk/24.0.8215888 did not have a source.properties file

FAILURE: Build failed with an exception.