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

Document how to use FTS5 on Android #371

Closed
jrr opened this issue Aug 12, 2019 · 16 comments · Fixed by #393
Closed

Document how to use FTS5 on Android #371

jrr opened this issue Aug 12, 2019 · 16 comments · Fixed by #393

Comments

@jrr
Copy link

jrr commented Aug 12, 2019

Searching through Github issues, it looks like FTS5 is unsupported on Android.

Here @brodybits references a repo that can be built to produce FTS5-supporting libs.

For this issue, I'd like:

  • FTS5 support out-of-the-box on Android
    -or-
  • An explanation as to why it's not offered, and advice how to work around it.

Would you like to support it, or are you specifically avoiding it for some reason? (would you accept contributions enable it?)

@jrr
Copy link
Author

jrr commented Aug 12, 2019

It looks like I'm getting the device's sqlite, not the one bundled with this library. Is this the "pure java" mode described in the readme? How can I use the bundled sqlite instead? (in order to attempt to replace it with my own build)

Edit: I continue to learn more!

I hadn't been through the how to use android guide because RN 0.60 magically autolinked it for me (as it did for another user).

One of the previously-necessary setup steps adds a gradle reference to node_modules/react-native-sqlite-storage/src/android, which is a sibling to node_modules/react-native-sqlite-storage/src/android-native. When manually-linked, can users opt for bundled sqlite by referencing android-native here instead of android? (is that how you use android native mode? this doesn't seem to be documented anywhere.)

What's the correct way to make that happen with 0.60's autolinking?

@carlosroberto555
Copy link
Contributor

carlosroberto555 commented Aug 13, 2019

I think we can make a gradle script to reference it
I can try make it on this weekend

Or, we can test to use react-native.config.js with dependency Android with project path to android-native (something like this like this)

@jrr
Copy link
Author

jrr commented Aug 13, 2019

Got it working! (FTS5 on Android) Here's what I did:

    "react-native-sqlite-storage": "jrr/react-native-sqlite-storage#fts5",

For now, anyone facing this issue can do the same!

Future

Long-term, I think my preference would be:

  1. for react-native-sqlite-storage's embedded binaries have FTS5 enabled, so anyone that uses android-native mode gets it.
  2. If that doesn't work for some reason, then I'd aim to keep a copy of the sqlite amalgamation in my RN project and build it as part of my project. (instead of e.g. checking-in a binary or referencing a forked project) I'm not sure what that would take.

@RAMart
Copy link

RAMart commented Aug 18, 2019

Related to #368

@andpor
Copy link
Owner

andpor commented Aug 22, 2019

auto-linking has been working with android version only (not native-android). I have been hinting to people to be careful submitting PR considering only android and leaving native-android behind. As of now I am not sure myself how to solve this.

@andpor
Copy link
Owner

andpor commented Aug 22, 2019

FTS5 should be working with binaries I have under this branch: new-native-sqlite-libs
If you can test these binaries and confirm they are all good I will merge them into the master and release ..

@carlosroberto555
Copy link
Contributor

Workaround on v4.0.0 is change sourceDir on ./node_modules/react-native-sqlite-storage/react-native.config.js for use android-native project

module.exports = {
  dependency: {
    platforms: {
      // ... another platforms
      android: {
        // sourceDir: './platforms/android'
        sourceDir: './platforms/android-native'
      }
    }
  }
}

@RAMart
Copy link

RAMart commented Aug 22, 2019

FTS5 should be working with binaries I have under this branch: new-native-sqlite-libs
If you can test these binaries and confirm they are all good I will merge them into the master and release ..

These are the ones I already checked in #368
A release would be highly appreciated.

@andpor
Copy link
Owner

andpor commented Aug 22, 2019

ok. I will include them in the next release 4.1.0

@jrr
Copy link
Author

jrr commented Aug 22, 2019

Those binaries are working for me, too!:

  • At first I tried out using the "andpor/react-native-sqlite-storage#new-native-sqlite-libs" branch directly, then realized it was out of date with master.
  • So then I took the libs from new-native-sqlite-libs, and applied them to latest master (commit).
  • And then applied @carlosroberto555 's new workaround to access android-native.

With this in place, I can see the FTS5 module is available in my app.

@andpor
Copy link
Owner

andpor commented Aug 22, 2019

yes, the branch has old structure...pre latest PR merge...

@jrr
Copy link
Author

jrr commented Aug 22, 2019

I propose a slight change to @carlosroberto555 's workaround, that would enable apps to opt in to android-native without having to edit any files or fork any repositories:

android: {
    sourceDir: `./platforms/android${process.env.USE_ANDROID_SQLITE_NATIVE ? "-native" : ""}`
}

This way you could e.g. USE_ANDROID_SQLITE_NATIVE=1 react-native run-android, or set it persistently via your environment config, however you set env vars in your project.

I would prefer some other, better-supported way of letting the consuming app configure libraries it depends on, but haven't found much documentation in this area. (it looks like maybe RN cli's native_modules.gradle is responsible for reading the config?).

In the mean time, how do you feel about shipping the environment variable approach?

@andpor
Copy link
Owner

andpor commented Aug 29, 2019

The new native libs have been merged and release under 4.1.0

@andpor
Copy link
Owner

andpor commented Aug 29, 2019

I will work on your suggestion for env switch next...i like the approach ..

@jrr
Copy link
Author

jrr commented Aug 29, 2019

I went ahead and created a PR: #377

@jrr
Copy link
Author

jrr commented Oct 30, 2019

I prefer #393's approach to this problem, which has you edit a file instead of setting an environment var. Anyone subscribed to the thread have thoughts on this?

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.

4 participants