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,
},
});
You can use Expo Sentry to find out what's causing the problem. However, it seems that the problem is linked to environment variables. When you build with eas, the .env file is not taken into account.
You can therefore add these variables to the channel corresponding to your build, as described in the documentation: https://docs.expo.dev/build/eas-json/#environment-variables