Expo App keep crashing when scanning QR project from Snack

Im using Expo 2.21.5 on android, when I scan my project from Snack to my expo app It keeps crashing without any notice, I can view it on “web view” on the Snack.expo.dev but when I try to run it on virtual devices “android/ios” it also shows nothing, just a homepage of the virtual phone.
But when I scan the default project it displays properly and didn’t crash.

Hi @dcit26-cs3a-magcuro

Do you get any error messages in the Snack logs?

Also, can you post a link to the snack?

@wodin thanks for response

no error message here’s the link
gnarly chocolates - Snack (expo.dev)

React Native does not support CSS, so I was surprised to see this:

import styles from './main.css';

I see that the file actually contains JavaScript code. Even so, I’m surprised it doesn’t cause problems. I suggest you rather rename it to something like styles.js and:

import styles from './styles';

One thing that can cause React Native to crash is if you use a string where it’s expecting a number. One place this can happen is in styles, where CSS is fine with e.g. "20px", React Native will want 20.
So change your “Welcome” line of code to:

        <Text style={{ fontSize: 20 }}>Welcome to Remind Me!</Text>

One way to track down crashes like this is to connect your phone to your computer via USB and run adb logcat after the app crashes. Then look for a fatal exception and see if the error messages around that give you and idea of what’s wrong.

Another way is to strip down the code to the bare minimum until it stops crashing. Then start adding stuff back again until it starts crashing again. This is what I did now. I started by removing the unused AssetExample and Card imports. Then I commented out the styles import and removed all of the style={...} attributes. At this point the app did not crash. I then started adding styles back in again and it crashed when I added back the style={{ fontSize: '20px' }}.

1 Like

Thank you so much! I just fixed the “import” part and the extension file from " .css to .js "
and the font, then I scanned and it works on my device! Thank you so much god bless!

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.