Fix "NDK did not have a source.properties file" Error
This comprehensive guide explains how to resolve the common Android development error where the NDK is missing the source.properties file, preventing your project from building successfully.
Problem Overview
The error occurs when Android Studio's build system cannot locate or validate the Native Development Kit (NDK) installation. The specific error message is:
Execution failed for task ':app:stripDebugDebugSymbols'.
NDK at ~/Library/Android/sdk/ndk-bundle did not have a source.properties fileThis typically happens because:
- The NDK installation is incomplete or corrupted
- The NDK path referenced in your project doesn't exist
- There's a mismatch between the expected and actual NDK versions
- The
ndk-bundledirectory is outdated or missing required files
Primary Solutions
Solution 1: Install or Reinstall NDK via Android Studio
The most reliable fix is to ensure you have a properly installed NDK version:
Open Android Studio SDK Manager:
- Go to File → Settings (Windows/Linux) or Android Studio → Preferences (macOS)
- Navigate to Appearance & Behavior → System Settings → Android SDK
- Select the SDK Tools tab
Install NDK:
- Check the box for NDK (Side by side)
- Click Show Package Details (bottom right)
- Select a stable NDK version (recommended: 26.1.10909125 or later)
- Click Apply and OK to install
INFO
Some projects, particularly Expo/React Native, may have compatibility issues with newer NDK versions. Version 26.1.10909125 is known to be stable for many use cases.
Solution 2: Specify NDK Version in build.gradle
Once you have installed the NDK, explicitly define the version in your module's build.gradle file:
android {
compileSdkVersion 33
ndkVersion "26.1.10909125" // Use your installed version
// Other configuration...
}WARNING
Ensure the version number matches exactly what you installed through the SDK Manager. You can find this in your SDK directory under ~/Library/Android/sdk/ndk/ (macOS) or C:\Users\username\AppData\Local\Android\Sdk\ndk\ (Windows).
Solution 3: Clean Up NDK Directories
If you have corrupted or incomplete NDK installations:
Navigate to your Android SDK's NDK directory:
- macOS:
~/Library/Android/sdk/ndk/ - Windows:
C:\Users\username\AppData\Local\Android\Sdk\ndk\
- macOS:
Remove problematic NDK versions (particularly the one mentioned in your error):
# Example for macOS
cd ~/Library/Android/sdk/ndk/
rm -rf 25.1.8937393 # Replace with your problematic version- Reinstall the NDK through Android Studio as described in Solution 1.
Solution 4: Update Local Properties File
The local.properties file may contain outdated NDK references:
- Open
android/local.propertiesin your project - Remove or update the
ndk.dirproperty:
# Remove this line entirely (recommended)
# ndk.dir=~/Library/Android/sdk/ndk-bundle
# Or update to point to a specific NDK version
ndk.dir=/Users/username/Library/Android/sdk/ndk/26.1.10909125DANGER
The ndk-bundle directory is deprecated. Modern Android development should use side-by-side NDK versions instead.
Additional Troubleshooting Steps
Accept Android Licenses
If you're using Flutter or other cross-platform tools, ensure Android licenses are accepted:
flutter doctor --android-licensesPress y to accept all licenses when prompted.
Clean and Rebuild Project
After making changes, clean your project:
# For Android projects
./gradlew clean
# For Flutter projects
flutter cleanThen rebuild your project.
Verify NDK Installation
Check that your NDK installation contains the required files, including source.properties. A complete NDK directory should look similar to:
ndk/26.1.10909125/
├── build/
├── meta/
├── ndk-build
├── ndk-gdb
├── ndk-stack
├── ndk-which
├── notice.html
├── package.xml
├── python-packages/
├── shader-tools/
├── simpleperf/
├── source.properties # This file must exist
├── sysroot/
├── toolchains/
└── wrap.shCommon Scenarios
React Native/Expo Projects
For React Native and Expo projects, NDK compatibility is crucial. Follow these specific steps:
- Install NDK version 26.1.10909125 through Android Studio
- Specify this exact version in
android/app/build.gradle:
android {
ndkVersion "26.1.10909125"
}- Remove any
ndk.dirreferences fromlocal.properties
Flutter Projects
Flutter projects may require additional configuration:
- Run
flutter doctorto check for any Android license issues - Add NDK version to
android/app/build.gradle:
android {
defaultConfig {
ndkVersion "26.1.10909125"
}
}- Run
flutter cleanbefore rebuilding
Prevention
To avoid this issue in the future:
- Always install NDK through Android Studio's SDK Manager rather than manual downloads
- Specify NDK versions explicitly in your
build.gradlefiles - Avoid modifying the
ndk.dirproperty inlocal.propertiesunless necessary - Regularly update your NDK installations through the SDK Manager
Conclusion
The "NDK did not have a source.properties file" error typically indicates an incomplete or misconfigured NDK installation. By following the solutions outlined above—installing the correct NDK version, specifying it in your build configuration, and cleaning up outdated references—you can resolve this issue and continue developing your Android application successfully.