SQLite4Unity3d icon indicating copy to clipboard operation
SQLite4Unity3d copied to clipboard

FTS support for Android

Open brookman opened this issue 6 years ago • 6 comments

Has the android .so (armeabi-v7a, 32bit) been built with FTS support? I am getting an error "No such module: fts4" when trying to run FTS queries on my Android device. On desktop it is working fine.

Unity: 2019.2.5f1 Build: Mono, ARMV7 Phone: Google Pixel 2XL, Android 10

brookman avatar Sep 13 '19 14:09 brookman

I'm not sure... So I would say most probably it wasn't.

robertohuertasm avatar Sep 13 '19 15:09 robertohuertasm

Thank you for the quick reply. We need the feature for our project, so I have manually compiled the Android libs with the corresponding flags (-DSQLITE_ENABLE_FTS4 and -DSQLITE_ENABLE_FTS5) from source. Let me know if you are interested in the binaries.

brookman avatar Sep 13 '19 20:09 brookman

Sure, can you make a PR with this? I'll be glad to merge it.

robertohuertasm avatar Sep 14 '19 09:09 robertohuertasm

I can try, but I am not an expert in SQLite (or C/compilers, cmake and Android native for that matter) and not entirely sure about the compile flags. For our use-cases I have built it with: -Os -s -DSQLITE_THREADSAFE=0 -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_RTREE

This means:

  • Optimized for file size
  • Stripping enabled
  • Not thread safe (so no dependency to pthreads)
  • No dynamic loading (not sure what that even is)
  • Extensions FTS4, FTS5, JSON1, RTREE

There are more flags listed in the documentation: https://www.sqlite.org/howtocompile.html For example -DSQLITE_ENABLE_EXPLAIN_COMMENTS. Which ones should I include?

For cmake I call it like this: cmake -DCMAKE_TOOLCHAIN_FILE=~/Android/Sdk/ndk/20.0.5594570/build/cmake/android.toolchain.cmake -DANDROID_ABI=armeabi-v7a -DANDROID_NATIVE_API_LEVEL=24 And the same with arm64-v8a and x86. I took API level 24 (Android 7.0, Nougat) as the minimum because our app needs that. But I can also go lower if needed.

Now there is also the question if the API 3.29 is still compatible with the C# code. I have only tested some very basic features which seem to work fine.

I am glad to make PR with the binaries if we can work out the build parameters.

brookman avatar Sep 14 '19 10:09 brookman

I see your point. Maybe we can leave it here. In case anyone else faces the same issue it will be enough to read this thread to find the solution.

I'm thinking it might be cool to have your compiled android libs in another repo folder just in case someone else wanted to use them but I'm not sure if that would confuse people or not.

robertohuertasm avatar Sep 14 '19 15:09 robertohuertasm

Thank you for the quick reply. We need the feature for our project, so I have manually compiled the Android libs with the corresponding flags (-DSQLITE_ENABLE_FTS4 and -DSQLITE_ENABLE_FTS5) from source. Let me know if you are interested in the binaries.

Hello, does your binary file have the RTree module enabled? I need a so under the Android platform.

chaoslife avatar Dec 14 '23 07:12 chaoslife