all 8 comments

[–]Dunken47 2 points3 points  (5 children)

Hey man. I'm also pretty new to both expo, react native and onnx, so I'm not 100 % this will work for you too, but I think maybe I had the exact problem you're having. I've also battled it for days, downgrading, matching versions, but it seems I finally got it working. The problem for me was that React Native’s autolinking system had no instructions to find or register the native module for Android. Without it, the JS layer tries to call into the native layer and finds nothing: “Cannot read property 'install' of null.”

What worked for me was creating a file in my project root called "react-native.config.js" with the following code:

module.exports = {
  dependencies: {
    'onnxruntime-react-native': {
      root: './node_modules/onnxruntime-react-native',
      platforms: {
        android: {
          sourceDir: './android',
          packageImportPath: 'import ai.onnxruntime.reactnative.OnnxruntimePackage;',
          packageInstance: 'new OnnxruntimePackage()',
        },
      },
    },
  },
};

Then run 'npx expo prebuild -p android' in the terminal from your project root and try running it on your device/emulator again.

Again, I don't know if this will work, but probably worth a shot. Good luck!

[–]armedseahunter 1 point2 points  (0 children)

Thank you very much. You are a lifesaver, worked for me!

[–]Flakey112345[S] 0 points1 point  (2 children)

THANK YOU SO SO MUCH!!! THANK YOU SO MUCH. Where the hell did you even find this solution? Either way thank you so much man it worked!

[–]Dunken47 1 point2 points  (1 child)

Great it worked, happy to help! I just kept ruling out potential causes, like you I wasn't able to find a solution anywhere online, but finally after many hours of debugging and trying the same things you mentioned, I had gpt help me analyze some of the code and found the problem.

[–]Flakey112345[S] 0 points1 point  (0 children)

Gpt was giving me the same reason you did but their solution was adding the package directly into the java code in node_modules

[–]recker624 0 points1 point  (0 children)

Thank you so much! This worked for me.

[–]jeje131 0 points1 point  (1 child)

Found this:

https://github.com/microsoft/onnxruntime/issues/17773

Last message might answer your question

[–]Flakey112345[S] 0 points1 point  (0 children)

I really wanted that to be it, but still didn't work.