Nozbe / WatermelonDB

🍉 Reactive & asynchronous database for powerful React and React Native apps ⚡️
https://watermelondb.dev
MIT License
10.63k stars 602 forks source link

How to enable fabric with react native 0.71++? Android version #1574

Open dnlsilva opened 1 year ago

dnlsilva commented 1 year ago

The documentation is quite outdated in terms of using fabric with android, there is this issue here: https://github.com/Nozbe/WatermelonDB/issues/1386 however it is also outdated and react native 0.71 does not have this file (android/app/src/main/java/yourappnamefolder/newarchitecture/MainApplicationReactNativeHost.java) anymore.

Where should I add the files to enable jsi on android?

17Amir17 commented 1 year ago

@radex Hey, can we please get an answer on this?

shaeinst commented 1 year ago

https://watermelondb.dev/docs/Installation#android-react-native

notmarinho commented 1 year ago

JSI still not working on Android with the new arch enable. The only solution that I found to use Watermelon with the new Arch is not implement the JSI config. @GleidsonDaniel

luanlcampos commented 1 year ago

Same here, @notmarinho. @radex any chance you could help us on that?

lucaswitch commented 1 year ago

The solution is to disable the new arch(Fabric only) on Android.

ebnersilva commented 1 year ago

@lucaswitch Thank you. It works here.

Can you explain to me the logic to disable the fabric?

mateusmarinhoo commented 1 year ago

Fabric There is no need to disable it. Works fine with fabric, but you should not do the JSI configuration recommended by the documentation

ebnersilva commented 1 year ago

@notmarinho if i disable the JSI in MainApplication.java, when I try to enable the turbo in sync it does not work.

Can you give me more details?

notmarinho commented 12 months ago

@ebnersilva I'm not using sync at the moment. Does it work if disable turbo?

To disable fabric on android

  1. Go to the file gradle.properties.
  2. It should have a variable called newArchEnabled in it.
  3. Change the value of it to newArchEnabled=false.
lucaswitch commented 12 months ago

@ebnersilva I'm not using sync at the moment. Does it work if disable turbo?

To disable fabric on android

1. Go to the file `gradle.properties`.

2. It should have a variable called `newArchEnabled` in it.

3. Change the value of it to `newArchEnabled=false`.

Make sure to run ./android/gradlew clean and run the build afterwards to changes be effective. Another solution is to disable JSI(On Android) in favor of using Fabric. All RN UI libraries are migrating from previous rendering engine to fabric, we must migrate as soon as possible in favor of keeping our apps stable.

Duell10111 commented 10 months ago

Is there any plans to migrate the library to the new architecture?

alexandre1921 commented 6 months ago

With the release of the react native 0.74 we cannot use JSI anymore so, we need turbo to keep using this library on the future. https://reactnative.dev/blog/2024/04/22/release-0.74#other-breaking-changes image

nmarchais commented 4 months ago

To use Turbo Login we need this piece of code in MainApplication.kt:

override fun getJSIModulePackage(): JSIModulePackage? { return JSIModulePackage { reactApplicationContext, jsContext -> val modules = mutableListOf<JSIModuleSpec<*>>() modules.addAll( WatermelonDBJSIPackage().getJSIModules( reactApplicationContext, jsContext ) ) } }

From react native 0.74.2, the method getJSIModulePackage() doesn't exist anymore. It seems this module has to be rewritten using TurboModule. Is there a workaround to use Turbo Login without using getJSIModulePackage() configuration? If not, can we expect a rewrite using TurboModule?

lucaswitch commented 4 months ago

We can make a pull request to add the existing jsi api into a turbo module.

What i know it's that the turbo module automatically creates the cpp ffi bindings( using a flow file) that @radex did by manually on current jsi implementation, see: _https://github.com/Nozbe/WatermelonDB/blob/master/native/android-jsi/src/main/cpp/DatabasePlatformAndroid.cpp and objective c equivalent.

We can achieve the same behavior using at least 50% or more the code that is already written and tested but i think it should be a major version bump.