Skip to content

Conversation

andrew-schenk
Copy link
Contributor

This PR fixes an issue where the Google Play Store would complain that this library was bundling non 16KB page aligned .so files.

Specifically

  • base/lib/x86_64/libtensorflowlite_gpu_jni.so
  • base/lib/x86_64/libtensorflowlite_jni.so

v1.4.0 of the litert fixes that without requiring a major update to v2.
google-ai-edge/LiteRT#43

Simply updating the dependency version wasn't enough because the directory structure of litert changes from 1.0.1 to 1.4.0

You can see that by going to maven and downloading and unzipping the 1.0.1 AAR and 1.4.0 AAR.

1.0.1 directory structure

headers/
--tensorflow/
----lite/

1.4.0 directory structure

headers/
--external/
----org_tensorflow/
----tensorflow/
--tflite/

This change in directory structure requires updated imports in this projects cpp files. from #include <tensorflow/lite to #include <tflite

There was also an issue with the internal litert cpp files not linking correctly because of the extra external/org_tensorflow/tensorflow path and the way this project copies over header files. I modified the gradle script to copy tensorflow up two levels

so this: turns into
headers/
--external/
----org_tensorflow/
----tensorflow/
--tflite/

this
headers/
--tensorflow/
--tflite/

@mrousavy
Copy link
Owner

mrousavy commented Jul 7, 2025

Is this written with AI? 😄

Did you test this change if everything runs on both iOS + Android?

@andrew-schenk
Copy link
Contributor Author

Parts of the gradle step were AI generated and then refined by myself. I tested on Android with the app I am working on and the ML model I am using was still working correctly.

@jslok
Copy link

jslok commented Aug 24, 2025

Not working for me.

ERROR TypeError: Cannot read property 'install' of undefined, js engine: hermes [Component Stack]
ERROR Warning: TypeError: Cannot read property 'useTensorflowModel' of undefined

@andrew-schenk
Copy link
Contributor Author

Not working for me.

ERROR TypeError: Cannot read property 'install' of undefined, js engine: hermes [Component Stack] ERROR Warning: TypeError: Cannot read property 'useTensorflowModel' of undefined

@jslok were you building off this branch? Did you clean out node_modules, android/build, and android/.gradle folders. yarn install, then did you run a clean project, and a gradle sync?

@jslok
Copy link

jslok commented Aug 25, 2025

Yep I tried this PR. Just tried again with full reinstall and gradle clean and same error. Also tried with a new clean project and got the same error. Using react-native 0.75.5 no expo no new arch.

@haidernawaz99
Copy link

haidernawaz99 commented Aug 31, 2025

Just FYI, Google Play Console complains about some additional libs at my end as well. Here is the full list:

        base/lib/arm64-v8a/libVisionCameraTflite.so
        base/lib/x86_64/libVisionCameraTflite.so
        base/lib/x86_64/libtensorflowlite_gpu_jni.so
        base/lib/x86_64/libtensorflowlite_jni.so

I'm not using vision camera lib in my project.

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 this pull request may close these issues.

4 participants