I just created me a new react native project on ubuntu lts with command npx @react-native-community/cli init and the project created just fine. after finishing with the project I CD into the project folder and run npx react-native run-android. and the error message it give me is Android/Sdk/ndk/27.1.12297006 did not have a source.properties file
1. Verify and Reinstall the NDK
The error suggests that the source.properties file is missing, which indicates an issue with the NDK installation. Follow these steps to reinstall the NDK: Open Android Studio. Go to File > Settings > Appearance & Behavior > System Settings > Android SDK (on macOS, it's under Preferences). Select the SDK Tools tab. Check the box for NDK (Side by side) and click Apply or OK to install the latest version of the NDK.
Once installed, verify that the NDK directory (e.g., ~/Android/Sdk/ndk/) contains the source.properties file.
2. Clean and Rebuild the Project
After reinstalling the NDK, clean and rebuild your project to ensure the changes take effect cd android ./gradlew clean cd .. npx react-native run-android 3. Specify the Correct NDK Version
Sometimes, the project may require a specific version of the NDK. You can specify the version in your build.gradle file: Open the android/build.gradle file. Add or update the ndkVersion property under the android block: gradle
android { ndkVersion "27.1.12297006" // Replace with the correct version } Sync the project and rebuild.
4. Delete and Reinstall the NDK Folder
If the issue persists, manually delete the NDK folder and reinstall it: Navigate to the NDK directory (e.g., ~/Android/Sdk/ndk/). Delete the problematic NDK folder (e.g., 27.1.12297006). Reinstall the NDK using Android Studio as described in Step 1.
5. Update Gradle and React Native
Ensure that you are using the latest versions of Gradle and React Native, as older versions may have compatibility issues with newer NDK versions: Update the Gradle wrapper by modifying the gradle-wrapper.properties file: properties
distributionUrl=https://services.gradle.org/distributions/gradle-8.0-all.zip Update React Native to the latest version: bash
npm install react-native@latest
6. Verify Environment Variables
Ensure that your ANDROID_HOME and PATH environment variables are correctly set: Add the following lines to your ~/.bashrc or ~/.zshrc file: bash
export ANDROID_HOME=$HOME/Android/Sdk export PATH=$ANDROID_HOME/emulator:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools:$PATH Reload the terminal: bash
source ~/.bashrc
7. Delete Gradle Cache