asg017 / sqlite-vec

A vector search SQLite extension that runs anywhere!
Apache License 2.0
3.75k stars 129 forks source link

Tracking issue: Android Support #68

Open asg017 opened 1 month ago

asg017 commented 1 month ago

sqlite-vec successfully compiles and run on Android (from what I tried on Termux on an old phone).

But how can we package and distribute sqlite-vec to make it easier for Android developers to use?

I don't know much about Android development or packages, so any help and insight would be greatly appreciated. I specifically have the following questions, so please answer in this thread if you know of an answer!

P.S. - if you're company or organization would benefit from sqlite-vec on Android, I'd love to have you as a sponsor!

Vali-98 commented 3 weeks ago

On the react-native side, expo-sqlite is capable of loading .so files as sqlite3 plugins with a bit of patching, as demonstrated in this patch file I made for my react-native app: https://github.com/Vali-98/ChatterUI/blob/master/patches/expo-sqlite%2B14.0.5.patch

Said function is unfortunately not exposed to the JS side of the library as of writing, but can be worked around.

For whatever reason, .so files in react-native seem to cause issues if not following the convention of lib<name>.so stemming from some mechanism in the SoLoader library used to load source files. I found that if proguard rules stripped the SoLoader errors, it will lead to a crash.

I would recommend the android source files be named libsqlitevec.so or something of that nature.

waqasakram117 commented 2 weeks ago
  • What Android SQLite client libraries are popular, and do they support dynamically loading SQLite extensions?
  • What "package managers" exist for 3rd party Android libraries?
  • How do Android libraries typically bundle pre-compiled shared object files?
ospfranco commented 2 weeks ago

Hey, I'm the author of op-sqlite. I want to integrate sqlite-vec into my library. The best way you can help RN, Android (and IOS) devs is by adding a make file rule that compiles an .so for android and a .a for iOS with a rule in the makefile.

For Android you need to be able to compile to 4 archs:

"x86_64-apple-ios", "aarch64-apple-ios", "aarch64-apple-ios-sim", "aarch64-linux-android", "armv7-linux-androideabi", "x86_64-linux-android", "i686-linux-android"

At least on Rust those are the name of the archs, no idea on how to compile C to those specific archs. Once the files are generated it's a matter of packaging them to be consumed on iOS (via an xcframework) and Android (via an AAR or just a file structure).

If you can provide some compilation instructions I can then integrate it into my library (and also expo-sqlite would follow the same steps)