Setting Up Android Studio on Linux for React Native (Expo) Development
This comprehensive guide will walk you through installing and configuring Android Studio on Linux specifically for React Native and Expo development. By the end of this guide, you'll have a fully functional development environment optimized for mobile app development.
- Prerequisites
- Installing Android Studio
- Initial Android Studio Configuration
- React Native/Expo Specific Setup
- Environment Variables Configuration
- Debugging and Development Tools
- Common Issues and Solutions
- Best Practices
Before starting, ensure you have:
- Ubuntu/Debian-based Linux distribution
- At least 8GB of RAM (16GB recommended)
- 10GB+ of free disk space
- Terminal access with sudo privileges
- Basic knowledge of command line operations
First, update your package manager and system packages:
sudo apt update && sudo apt upgrade -yWe'll use the official PPA repository for the most up-to-date version:
# Add the repository for Android Studio
sudo add-apt-repository ppa:maarten-fonville/android-studio -y
# Update package list
sudo apt update
# Install Android Studio
sudo apt install android-studio -yLaunch Android Studio to verify the installation:
android-studio- Welcome Screen: Click "Next" to start the setup wizard
- Install Type: Choose "Standard" for typical development setup
- UI Theme: Select your preferred theme (Darcula or Light)
- SDK Components: The wizard will automatically download:
- Android SDK
- Android SDK Platform
- Android Virtual Device (AVD)
- Latest Android SDK build-tools
To verify everything works correctly:
- Create a new Kotlin project
- Select "Empty Activity" template
- Click "Finish" and wait for Gradle sync
- Click the "Run" button (green play icon) to test compilation
This is essential for React Native/Expo projects to work properly with Android Studio.
Why this matters: The default launch script (studio.sh) doesn't load the Node.js environment properly, causing issues with Gradle configurations that use Node.js commands.
Edit the desktop application file:
sudo nano /usr/share/applications/android-studio.desktopChange the Exec line from:
Exec=/opt/android-studio-2025.1.1/android-studio/bin/studio.sh
To:
Exec=/opt/android-studio-2025.1.1/android-studio/bin/studio
Alternatively, always launch Android Studio from the terminal:
/opt/android-studio-2025.1.1/android-studio/bin/studioNote: Update the path according to your Android Studio version.
React Native projects use Gradle configurations that execute Node.js commands:
def reactNativeAndroidDir = new File(
providers.exec {
workingDir(rootDir)
commandLine("node", "--print", "require.resolve('react-native/package.json')")
}.standardOutput.asText.get().trim(),
"../android"
)Without proper Node.js environment loading, these commands fail, causing build errors.
Add these environment variables to your ~/.bashrc or ~/.zshrc:
# Open your shell configuration file
nano ~/.bashrc
# Add these lines at the end:
# Set JAVA_HOME to the JDK bundled with Android Studio
export JAVA_HOME="/opt/android-studio-2025.1.1/android-studio/jbr"
export PATH="$JAVA_HOME/bin:$PATH"
# Android SDK paths
export ANDROID_HOME="$HOME/Android/Sdk"
export ANDROID_SDK_ROOT="$ANDROID_HOME"
export PATH="$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$PATH"
# React Native development
export PATH="$PATH:$ANDROID_HOME/emulator"
export PATH="$PATH:$ANDROID_HOME/platform-tools"# Reload your shell configuration
source ~/.bashrc
# Verify the environment variables
echo $JAVA_HOME
echo $ANDROID_HOMEIn Android Studio, go to:
- File → Settings (or Android Studio → Preferences on some systems)
- Appearance & Behavior → System Settings → Android SDK
- Verify that the SDK path matches your
ANDROID_HOMEvariable
Android Studio provides excellent debugging tools for React Native/Expo development:
The Logcat window displays real-time logs from your device/emulator:
How to access:
- View → Tool Windows → Logcat
- Filter logs by app package name
- Use different log levels (Verbose, Debug, Info, Warn, Error)
For advanced debugging of background tasks, network requests, and databases:
How to access:
- View → Tool Windows → App Inspection
- Inspect network traffic
- View database contents
- Monitor background tasks
View and modify files on your device/emulator:
How to access:
- View → Tool Windows → Device File Explorer
- Navigate to
/data/data/[your-app-package]/ - Useful for debugging storage issues
-
ADB (Android Debug Bridge):
# List connected devices adb devices # Install APK adb install path/to/your/app.apk # View device logs adb logcat
-
Emulator Management:
- Tools → AVD Manager
- Create multiple device configurations
- Test different Android versions
This error occurs when Expo modules aren't properly configured in your Android project.
Solution:
-
First, try reopening Android Studio and reloading the project
-
Clean and reinstall dependencies:
rm -rf node_modules npm install # or yarn install -
Verify your
android/settings.gradlefile:
pluginManagement {
def reactNativeGradlePlugin = new File(
providers.exec {
workingDir(rootDir)
commandLine("node", "--print", "require.resolve('@react-native/gradle-plugin/package.json', { paths: [require.resolve('react-native/package.json')] })")
}.standardOutput.asText.get().trim()
).getParentFile().absolutePath
includeBuild(reactNativeGradlePlugin)
def expoPluginsPath = new File(
providers.exec {
workingDir(rootDir)
commandLine("node", "--print", "require.resolve('expo-modules-autolinking/package.json', { paths: [require.resolve('expo/package.json')] })")
}.standardOutput.asText.get().trim(),
"../android/expo-gradle-plugin"
).absolutePath
includeBuild(expoPluginsPath)
}
plugins {
id("com.facebook.react.settings")
id("expo-autolinking-settings")
}
extensions.configure(com.facebook.react.ReactSettingsExtension) { ex ->
if (System.getenv('EXPO_USE_COMMUNITY_AUTOLINKING') == '1') {
ex.autolinkLibrariesFromCommand()
} else {
ex.autolinkLibrariesFromCommand(expoAutolinking.rnConfigCommand)
}
}
expoAutolinking.useExpoModules()
rootProject.name = 'your-app-name'
expoAutolinking.useExpoVersionCatalog()
include ':app'
includeBuild(expoAutolinking.reactNativeGradlePlugin)- If the issue persists, regenerate native code:
npx expo prebuild --clean
Common causes and solutions:
- Node.js not found: Ensure you're using the correct Android Studio launcher (not
studio.sh) - JDK version mismatch: Use the bundled JDK in Android Studio
- Network issues: Configure proxy settings if behind a corporate firewall
Optimization tips:
-
Enable Hardware Acceleration:
# Check if KVM is available grep -E "(vmx|svm)" /proc/cpuinfo # Install KVM if not present sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils
-
AVD Configuration:
- Allocate sufficient RAM (2GB minimum)
- Enable "Use Host GPU" in AVD settings
- Use x86_64 images for better performance
- Never directly edit the
android/folder in Expo projects - Use Expo Config Plugins for native modifications
- Keep custom native modules in separate directories
Only modify autolinking settings if you have specific requirements:
{
"expo": {
"name": "your-app-name",
"autolinking": {
"searchPaths": ["../../packages"],
"nativeModulesDir": "../../packages"
}
}
}- Use Expo CLI for project creation and management
- Test on real devices when possible
- Use Android Studio for:
- Native code debugging
- Performance profiling
- Advanced logging
- Build analysis
- Keep Android Studio updated
- Use specific Android SDK versions for consistency
- Document your environment setup in project README
Before asking for help, verify:
- Android Studio launches with the correct script
- Environment variables are set correctly
- Node.js is accessible from Android Studio
- Gradle can execute Node.js commands
- Expo CLI is up to date
- Project dependencies are installed
With Android Studio properly configured on Linux, you now have a powerful development environment for React Native and Expo projects. The key points to remember:
- Use the correct launcher to ensure Node.js integration
- Set up environment variables properly
- Leverage Android Studio's debugging tools for efficient development
- Follow Expo best practices for native code modifications
This setup will provide you with professional-grade tools for mobile app development, from initial coding to debugging and performance optimization.

