Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build Error on React Native 0.71.0 #497

Closed
hamdij0maa opened this issue Jan 12, 2023 · 40 comments · Fixed by #499
Closed

Build Error on React Native 0.71.0 #497

hamdij0maa opened this issue Jan 12, 2023 · 40 comments · Fixed by #499

Comments

@hamdij0maa
Copy link

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

  • What went wrong:
    A problem occurred evaluating project ':react-native-mmkv'.
    **/node_modules/react-native/android' to contain exactly one file, however, it contains no files.
@tobua
Copy link

tobua commented Jan 12, 2023

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
Copy link

retyui commented Jan 13, 2023

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
Copy link
Author

👎🏼for Fabric yes, but our need is using RN 0.71.X without Fabric

@retyui
Copy link

retyui commented Jan 13, 2023

👎🏼for Fabric yes, but our need is using RN 0.71.X without Fabric

Why you can't use the Fabric?

@hamdij0maa
Copy link
Author

👎🏼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
Copy link

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
Copy link
Author

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

@tobua
Copy link

tobua commented Jan 13, 2023

@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
Copy link
Author

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
Copy link
Author

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

  • Where:
    Build file '/Users/*****/Desktop/apps/****/node_modules/react-native-mmkv/android/build.gradle' line: 173

  • What went wrong:
    A problem occurred evaluating project ':react-native-mmkv'.

Expected directory '/Users/*****/Desktop/apps/****/node_modules/react-native/android' to contain exactly one file, however, it contains no files.

@tobua
Copy link

tobua commented Jan 13, 2023

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

@hamdij0maa
Copy link
Author

@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
Copy link
Collaborator

Titozzz commented Jan 13, 2023

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
Copy link
Author

Yes, just confirming 😂

@leonardoballand

This comment was marked as duplicate.

@ugurdalkiran

This comment was marked as spam.

@meftunca

This comment was marked as abuse.

@hamdij0maa

This comment was marked as spam.

@ugurdalkiran

This comment was marked as spam.

@mrousavy
Copy link
Owner

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
Copy link
Owner

@Titozzz is helping me with the RN 0.71 release. We're working on it (#480). It's not as easy as it looks, so be patient. Thanks @Titozzz ❤️

@mrousavy
Copy link
Owner

Just published 2.6.0, this should work on RN 0.71 with new and old architecture! 🚀 Thanks for your help @Titozzz ❤️

@hamdij0maa
Copy link
Author

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
Copy link

tobua commented Jan 16, 2023

Working fine for me, thanks!

@ugurdalkiran
Copy link

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
Copy link
Author

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
Copy link

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
Copy link
Owner

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

@mrousavy
Copy link
Owner

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
Copy link

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

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

@abgaryanharutyun
Copy link

abgaryanharutyun commented Jan 16, 2023

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
Copy link

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
Copy link
Contributor

inssein commented Jan 17, 2023

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
Copy link
Contributor

inssein commented Jan 17, 2023

@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: #499. Feel free to close if not relevant.

@ugurdalkiran
Copy link

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
Copy link

Works like a charm! 💟

@mrousavy
Copy link
Owner

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
Copy link
Contributor

inssein commented Jan 17, 2023

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
Copy link

98rahul commented Jan 23, 2023

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
Copy link

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.

  • What went wrong:
    A problem occurred configuring project ':react-native-mmkv'.

NDK is not installed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.