Expo with Supabase crashes on device but works on Expo Go

I have an expo app with supabase. It works find on Expo Go but when I build an apk and install it on a real device, it crashes. After investigation, I have found out that supabase is the reason for this because when I remove supabase, it works fine. Also, pages that are not calling supabase work fine. Has anyone encountered this before? How did you solve it?
I am using expo SDK 49
Here is my supabase code

import "react-native-url-polyfill/auto";
import AsyncStorage from "@react-native-async-storage/async-storage";
import { createClient } from "@supabase/supabase-js";

const supabaseUrl = SUPABASE_URL as string;
const supabaseAnonKey = SUPABASE_KEY as string;

export const supabase = createClient(supabaseUrl, supabaseAnonKey, {
  auth: {
    storage: AsyncStorage,
    autoRefreshToken: true,
    persistSession: true,
    detectSessionInUrl: false,
  },
});

  • Did you install supabase-js using npx expo install ..... to be sure you are getting the version that is compatible with the version of Expo you are using? (You should always try installing dependencies using npx expo install ......). See if you can get the “system logs” from the Android device or simulator when the app crashes. It would be good to know what the specific stack trace is.

    – 

  • Yes I did install using npx expo install. I followed this link supabase.com/docs/guides/getting-started/tutorials/…

    – 

  • So I think the next step is to look for the specific stack trace in the system logs. See this doc: docs.expo.dev/workflow/logging/#system-logs

    – 

Leave a Comment