Photo by Possessed Photography on Unsplash
Mastering Your First React Native Project: A Comprehensive Guide π§βπ»
When I initially began working on my react-native application, it seemed like a daunting task as my emulator struggled to display the boilerplate codeπ¨βπ» on the screen. I wondered what mistake I had made, but after hours of puzzling π΅ over it, I discovered a simple solution (which actually only took a few minutes β³ to fix).
Here are the steps below:
Open your React Native project.
Right-click on the project folder, select "Open in Terminal," and enter 'code .' to open the project in VSCode.
Start the Metro bundler by running the command 'npx react-native start'. This will launch the Metro bundler, which runs on port 8081 and provides several options, including:
'i' for running on iOS
'a' for running on Android
'd' to open the Dev Menu
'r' to reload the app
Choose the 'a' option to run the app on Android.
If you encounter the error message stating "SDK location not found," follow these additional steps:
Create a new file named "local.properties" inside the "android" directory of your project.
Add the following line to the "local.properties" file according to your system preferences:
//for windows
sdk.dir=C\:\\Users\\username\\AppData\\Local\\Android\\Sdk
//for mac
sdk.dir=/Users/username/Library/Android/sdk
Replace 'username' with your actual username.
By following these steps, you should be able to resolve the SDK location issue and continue developing your React Native application smoothly π€π.