FAQ
Step-by-step diagnostic procedures and solutions for common setup, build, and development issues in React Native.
1. Setup & Environment
Q1. What prerequisites are required before the React Native workshop?
Android Development Requirements
- Node.js (LTS v20+ or v22.11+)
- npm package manager
- JDK 17 (Zulu or Microsoft OpenJDK)
- Android Studio (Latest stable version)
- Android SDK Platform (API 34)
- Android SDK Build-Tools
- Android SDK Platform-Tools (
adb) - Android Emulator or physical Android device with USB debugging enabled
- VS Code with React Native / TypeScript extensions
- Git
For iOS development, macOS users also require Xcode and CocoaPods.
Complete all setup steps before the session to avoid installation issues during hands-on coding exercises.
Q2. My terminal says "command not found" or "not recognized as an internal or external command".
Example errors:
command not found: node
or on Windows:
'node' is not recognized as an internal or external command
Common Causes & Solutions
- Software not installed: Download and run the official installer.
- Missing from PATH: The program directory is not included in system
PATH. - Terminal opened before installation: Restart the terminal or VS Code window.
Q3. I installed something but the terminal still cannot find it.
Restart the following applications to reload system environment variables:
- Terminal / PowerShell
- VS Code
- Android Studio
If necessary, restart the computer. Environment variable changes are not visible to applications that were already running.
2. Java & JDK
Q4. Why does React Native Android need Java?
Android builds use Gradle, and Gradle requires a compatible Java Virtual Machine runtime (JDK 17).
Verify your installed Java version:
java -version
javac -version
Q5. I get "JAVA_HOME is not set". What should I do?
Configure the JAVA_HOME environment variable to point to your JDK directory.
- Windows (PowerShell)
- macOS / Linux
echo $env:JAVA_HOME
java -version
Set JAVA_HOME in System Properties → Environment Variables to your JDK path (e.g. C:\Program Files\Microsoft\jdk-17.x.x).
echo $JAVA_HOME
Add to ~/.zshrc:
export JAVA_HOME=$(/usr/libexec/java_home -v 17)
Restart your terminal afterward.
Q6. I have multiple Java versions installed. Which one should I use?
Check your active Java version:
java -version
and check Gradle's runtime Java:
cd android
./gradlew -version
Use JDK 17 for modern React Native. Do not assume the newest Java version (e.g. Java 21+) is automatically compatible with older Gradle plugins.
3. Android Studio & SDK
Q7. What should I install in Android Studio?
In Android Studio → Settings/Preferences → Languages & Frameworks → Android SDK, ensure these are installed:
- Android SDK
- Android SDK Platform (API 34)
- Android SDK Build-Tools
- Android SDK Platform-Tools
- Android Emulator
- Android SDK Command-line Tools
Q8. Where can I find Android SDK settings?
In Android Studio, navigate to: Settings/Preferences → Languages & Frameworks → Android SDK
Default paths:
- macOS:
~/Library/Android/sdk - Windows:
%LOCALAPPDATA%\Android\Sdk
Q9. Android Studio has an SDK, but React Native cannot find it.
Set ANDROID_HOME in your environment, or specify it explicitly in android/local.properties:
- Windows (android/local.properties)
- macOS (android/local.properties)
sdk.dir=C\:\\Users\\<Your-Username>\\AppData\\Local\\Android\\Sdk
sdk.dir=/Users/<Your-Username>/Library/Android/sdk
Q10. I get "SDK location not found".
Check:
- Android Studio has the Android SDK installed.
ANDROID_HOMEenvironment variable is configured.- Platform-Tools is installed.
- Your terminal was restarted after changing environment variables.
Q11. What is adb?
adb stands for Android Debug Bridge. It allows your computer to communicate with connected Android devices and emulators.
Verify adb:
adb version
adb devices
Q12. adb is not recognized as a command.
Your Android SDK platform-tools directory is missing from PATH.
- Windows: Add
%LOCALAPPDATA%\Android\Sdk\platform-toolsto UserPath. - macOS: Add
export PATH=$PATH:$ANDROID_HOME/platform-toolsto~/.zshrc.
Restart the terminal after updating.
4. Emulator & Physical Device
Q13. How do I create an Android Emulator?
In Android Studio:
- Open Device Manager → Create Device.
- Choose a hardware profile (e.g. Pixel 7).
- Select an Android system image (API 34).
- Click Finish, then press the Play button to start the emulator.
Q14. The Android Emulator is very slow.
- Enable hardware virtualization in BIOS (Intel VT-x / AMD-V).
- Allocate at least 2048 MB RAM in emulator settings.
- Use an x86_64 system image (or ARM64 on Apple Silicon).
- Close heavy background applications.
Q15. The emulator is stuck on the boot screen.
- Stop the emulator.
- Start it with Cold Boot Now from the Device Manager menu.
- If still stuck, select Wipe Data.
- Recreate the emulator if wiping data fails.
Q16. React Native says no Android device was found.
Run:
adb devices
If the list is empty, start the Android emulator or connect a physical device with USB debugging enabled.
Q17. Can I use my physical Android phone?
Yes.
- Enable Developer Options (tap Build Number 7 times in Settings → About Phone).
- Turn on USB Debugging.
- Connect the phone to your computer via USB.
- Run
adb devicesto confirm connection.
Q18. My phone shows "unauthorized" in adb devices.
Unlock your phone and accept the prompt: "Allow USB debugging from this computer?". Check "Always allow" and tap OK.
Then run:
adb devices
Q19. My phone does not appear in adb devices.
- Use a data-transfer capable USB cable (some cables only provide power).
- Change USB mode on your phone to File Transfer (MTP).
- Install OEM USB drivers on Windows.
- Try a different USB port.
5. React Native Setup
Q20. How do I create a React Native project?
Initialize using the React Native Community CLI:
npx @react-native-community/cli@latest init ReactionGame
cd ReactionGame
Q21. Should I use Expo or React Native CLI?
- Expo: Best for beginners and quick prototypes without complex native build setup.
- React Native CLI: Required when working directly with native Android/iOS code, Gradle, or native SDK integrations.
Q22. I created the project in the wrong folder.
Navigate to the correct folder in your terminal:
cd path/to/ReactionGame
ls
Confirm that package.json, android/, and src/ exist in the directory.
Q23. How do I run the React Native Android app?
In the project root directory:
npm start
In a second terminal window:
npm run android
Q24. npm run android says no device is connected.
Verify connected devices:
adb devices
Start the emulator from Android Studio or connect your physical device.
6. Metro & Dependencies
Q25. What is Metro?
Metro is React Native's JavaScript/TypeScript bundler. It compiles, bundles, and serves your code to the running application with Fast Refresh.
Q26. Metro is showing old code.
Restart Metro with a clean cache:
npx react-native start --reset-cache
Then reload the app by pressing R twice on the Android emulator.
Q27. I get "Unable to resolve module".
Example:
Unable to resolve module './Button'
Checklist
- Ensure the file exists at the specified relative path.
- Check case-sensitivity (
Button.tsxvsbutton.tsx). - If importing a third-party library, verify it is listed in
package.jsonand runnpm install.
Q28. I get "No script URL provided".
- Ensure the Metro bundler is running (
npm start). - Verify emulator or physical device can reach the host machine.
- Reload the application.
Q29. npm install fails.
- Verify Node and npm versions:
node --version,npm --version. - Ensure you are inside the project folder containing
package.json. - Run
npm install.
Q30. npm shows an ERESOLVE dependency conflict.
Identify which package versions conflict before using override flags. If necessary for the workshop dependencies, use:
npm install --legacy-peer-deps
Q31. node_modules looks broken.
To perform a clean reinstall of dependencies:
- Windows (PowerShell)
- macOS / Linux
Remove-Item -Recurse -Force node_modules
npm install
rm -rf node_modules
npm install
7. Gradle & Android Build
Q32. What is Gradle?
Gradle is the native build system for Android. It compiles Java/Kotlin/C++ source code, downloads native dependencies, and packages the Android APK.
Q33. I get "Gradle build failed". What should I read?
Do not stop at BUILD FAILED. Look up in the terminal output for:
What went wrong:Caused by:
To view full stack trace information:
cd android
./gradlew assembleDebug --stacktrace
Q34. Gradle cannot download dependencies.
- Check internet connection, proxy, or VPN.
- Some company networks block Gradle maven repositories.
- Run
./gradlew build --refresh-dependenciesinandroid/.
Q35. I have a Gradle dependency version conflict.
Avoid randomly modifying Gradle, Kotlin, or React Native versions in android/build.gradle. Keep dependencies aligned with the project repository version.
Q36. The Android build broke after I changed Java.
Verify Java runtime version:
java -version
cd android
./gradlew -version
Confirm that Gradle is using JDK 17.
8. TypeScript
Q37. What is TypeScript?
TypeScript adds static type definitions to JavaScript, catching type errors during development before runtime.
const score: number = 10;
Q38. What is the difference between .js, .ts, and .tsx?
.js: Standard JavaScript.ts: TypeScript without JSX.tsx: TypeScript containing JSX (React Native UI components)
Q39. TypeScript rejects code that JavaScript would accept.
// Invalid in TypeScript
const score: number = "10";
// Correct
const score: number = 10;
Q40. I get "Type 'string' is not assignable to type 'number'".
Parse string values (such as text input results) before assigning them to numeric variables:
const score: number = Number(inputValue);
Q41. I get "Object is possibly 'undefined'".
Use optional chaining (?.) or fallback values (??):
const userName = user?.name ?? "Guest";
Q42. I get "Property does not exist on type".
Update your interface or type definition to include the property:
type Player = {
id: string;
name: string;
score: number;
};
Q43. Should I use 'any' to remove TypeScript errors?
Avoid any as a default workaround. Use explicit interfaces to retain autocomplete and type verification.
9. React Native Coding & UI
Q44. What is JSX?
JSX allows you to write component UI structure inside JavaScript and TypeScript:
<View>
<Text>Hello React Native</Text>
</View>
Q45. "View is not defined" or "Text is not defined".
Import core components from 'react-native':
import { View, Text } from "react-native";
Q46. My JSX tag is not closed properly.
Every JSX element must be properly closed:
<View>
<Text>Hello</Text>
</View>
Q47. Why can't I use div, button, p, img, or input?
React Native does not use browser HTML elements. Use native components:
<div>→<View><p>/<span>→<Text><button>→<Pressable><img>→<Image><input>→<TextInput>
Q48. What are props?
Props allow parent components to pass data to child components:
type PlayerProps = {
name: string;
};
function Player({ name }: PlayerProps) {
return <Text>{name}</Text>;
}
// Usage:
<Player name="Alex" />
Q49. TypeScript says a prop is missing.
Provide all required props or mark them optional in the type definition with ?:
type PlayerProps = {
name: string;
score?: number;
};
Q50. How do I make a prop optional?
Add a question mark ? next to the property name in the type definition:
type PlayerProps = {
name: string;
score?: number;
};
Q51. How do I create and use state?
const [score, setScore] = useState(0);
Q52. Why is changing a state variable directly wrong?
Never mutate state directly:
// Incorrect: Will not trigger UI re-render
score = score + 1;
// Correct
setScore(score + 1);
Q53. When should I use the previous-state updater function?
Use the updater function when the new value depends on the previous state:
setScore((prev) => prev + 1);
Q54. My state has the wrong TypeScript type.
Provide an explicit generic type to useState:
const [user, setUser] = useState<User | null>(null);
Q55. What is useEffect used for?
Common use cases include API fetching, subscriptions, setting intervals/timers, and synchronizing with external systems.
Q56. What does an empty dependency array [] mean?
useEffect(() => {
console.log("Component mounted");
}, []);
The effect runs once when the component mounts.
Q57. My useEffect runs in an infinite loop.
Avoid updating state inside an effect if that same state variable is in the dependency array:
// Incorrect: Triggers re-render on every score update
useEffect(() => {
setScore(score + 1);
}, [score]);
Q58. My timer keeps running after switching screens.
Return a cleanup function from useEffect:
useEffect(() => {
const interval = setInterval(() => {
// Timer tick
}, 1000);
return () => clearInterval(interval);
}, []);
Q59. How do I handle button press events?
<Pressable onPress={handlePress}>
<Text>Tap Here</Text>
</Pressable>
Q60. My button function executes immediately on render.
Pass a function reference, not a function call:
// Incorrect: Executes during render
<Pressable onPress={handlePress()} />
// Correct
<Pressable onPress={handlePress} />
// Correct with arguments
<Pressable onPress={() => handlePress(id)} />
Q61. How do I style React Native components?
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: "center",
justifyContent: "center",
},
});
Q62. Why doesn't standard CSS syntax work?
React Native styles use camelCase property names:
backgroundColor: "blue"(notbackground-color: blue)fontSize: 16(notfont-size: 16px)
Q63. My screen does not fill the device viewport.
Apply flex: 1 to the root container view:
container: {
flex: 1,
}
Q64. My layout is arranged horizontally instead of vertically.
React Native defaults to flexDirection: "column". Check if flexDirection: "row" was set on the container.
Q65. My randomly positioned elements render outside the screen.
Calculate random positions using device dimensions from Dimensions.get('window') or useWindowDimensions(), subtracting element width and safe area margins.
Q66. How do I display a scrollable list of items?
Use FlatList:
<FlatList
data={players}
keyExtractor={(item) => item.id}
renderItem={({ item }) => <Text>{item.name}</Text>}
/>
Q67. FlatList warns about missing keys.
Supply a keyExtractor returning unique IDs:
keyExtractor={(item) => item.id}
Q68. FlatList is not scrolling.
- Check if parent container has
flex: 1. - Avoid nesting a
FlatListinside aScrollViewwith the same scroll direction.
Q69. How does navigation work in React Native?
React Navigation manages navigation stacks and tabs between screens (Home → Game → Result).
Q70. Screen not found navigation error.
Verify the route name matches the name registered in your navigator configuration.
Q71. TypeScript navigation parameters are invalid.
Define a param list type for your navigator:
type RootStackParamList = {
Home: undefined;
Game: { difficulty: string };
Result: { score: number };
};
10. Debugging
Q78. How should I debug React Native issues?
- Inspect console logs in the Metro terminal.
- Check the on-screen RedBox error stack trace.
- Use
console.log("key:", value)targeted logs.
Q79. I see a RedBox error screen. What should I read?
Read the first error at the top:
- Error name
- Target file name
- Line number
- Top line of the stack trace
Q80. The app crashes unexpectedly without clear logs.
- Run
npx react-native log-androidto view native logcat logs. - Revert your most recent changes incrementally to identify the regression.
Q81. Should I leave console.log statements in code?
Use targeted debugging logs during development, and clean them up before finalizing code.
11. Emergency Recovery
Q89. Everything is broken. What is the reset sequence?
Follow this recovery order:
- Device:
adb devices - Metro:
npx react-native start --reset-cache - Gradle:
cd android && ./gradlew clean && cd .. - Build:
npm run android
Q90. Should I delete node_modules and Gradle caches immediately?
No. Identify the specific error first. Re-downloading entire caches takes time and can introduce new dependency issues.