How to Install Android NDK: Complete Setup Guide
In this article
Installing the Android Native Development Kit (NDK) enables you to write high-performance code in C and C++ for your Android applications. This is essential for game engines, signal processing, or any task requiring direct hardware access. To begin, ensure you have the latest version of Android Studio installed on your computer, as it provides the most reliable way to manage the NDK alongside other development tools.
What You'll Need
- A Windows, macOS, or Linux computer with at least 10GB of free disk space.
- The latest version of Android Studio installed and launched at least once.
- A stable internet connection to download the SDK packages.
- Basic familiarity with command-line interfaces or Android Studio menus.
Step-by-Step
- Open Android Studio Settings: Launch Android Studio. On Windows or Linux, navigate to
File > Settings. On macOS, go toAndroid Studio > Settings(orPreferencesin older versions). Alternatively, use the keyboard shortcutCtrl+Alt+Son Windows/Linux orCmd+,on macOS. - Navigate to SDK Manager: In the left-hand sidebar of the Settings window, select
Appearance & Behavior > System Settings > Android SDK. This opens the SDK Manager interface where all platform components are managed. - Select the SDK Platforms Tab: Ensure you are on the "SDK Platforms" tab at the top of the window. Check the box next to the Android API level you intend to target (e.g., Android 14.0 / API 34). If you are unsure, selecting the latest available API is generally safe for new projects.
- Switch to SDK Tools Tab: Click the "SDK Tools" tab located next to the platforms tab. This section contains the build tools and native libraries required for compilation.
- Enable NDK (Side by Side): Look for the checkbox labeled "NDK (Side by side)". Check this box. The current recommended approach is to install specific versions of the NDK rather than the legacy "Android NDK" package, which is deprecated. Select the latest version from the dropdown menu that appears after checking the box.
- Apply Changes: Click the "OK" button at the bottom right of the window. A confirmation dialog will appear asking if you want to proceed with the installation. Click "OK" again.
- Wait for Download: Android Studio will now download and install the selected NDK version. This process may take several minutes depending on your internet speed. A progress bar will show the status. Do not close the window during this time.
- Verify Installation: Once the installation completes, click "Finish". Return to the main Android Studio window. Open a project's
local.propertiesfile. You should see a line similar tondk.dir=/path/to/sdk/ndk/[version]. This confirms the IDE has recognized the installation.
Common Mistakes
One frequent error is attempting to use the old "Android NDK" package instead of "NDK (Side by side)". The legacy package installs a single global version that can conflict with different projects requiring different NDK levels. Always prefer the side-by-side installation method.
Another common issue is forgetting to sync the project after installation. Even if the NDK is downloaded, your build system might not recognize it until you click "Sync Project with Gradle Files" in the toolbar. Always perform this sync step immediately after installing native tools.
Users also sometimes overlook architecture compatibility. Ensure you are downloading the correct NDK variant for your host machine (x86_64 for Intel/AMD Macs and PCs, arm64 for Apple Silicon Macs). While the NDK handles cross-compilation, the host tools must match your OS architecture.
Tips
Keep your NDK versions consistent across your team. Define the specific NDK version in your build.gradle file using the android.ndkVersion property. This prevents build failures when another developer uses a different local version.
Use the Command Line Tools for automation. If you are setting up CI/CD pipelines, you can accept licenses and install the NDK via command line using sdkmanager --install "ndk;[version]". This is faster than using the GUI for automated setups.
Monitor disk usage. The NDK and associated tools can consume significant space. If you are low on storage, delete unused SDK platforms or older NDK versions via the SDK Manager's "Show Package Details" option to reclaim space.
Troubleshooting
If the installation fails or hangs, first check your internet connection and firewall settings. Corporate networks often block SDK downloads. Try switching to a mobile hotspot or a different network to rule out connectivity issues.
If Android Studio reports a license error, open the terminal and run ./sdkmanager --licenses (Linux/macOS) or sdkmanager.bat --licenses (Windows). Accept the licenses manually before retrying the installation through the GUI.
If the build fails with "NDK not found" errors, verify your local.properties file points to the correct path. Sometimes, moving the SDK folder requires updating this path manually. You can find the correct path by looking at the "SDK Location" field in the SDK Manager.
In rare cases, corrupted downloads cause issues. Navigate to your SDK directory (usually ~/Android/Sdk on Mac/Linux or C:\Users\[User]\AppData\Local\Android\Sdk on Windows), delete the ndk folder, and reinstall via the SDK Manager. This forces a clean download.
Frequently Asked Questions
Do I need the NDK for every Android app?
No. Most apps built entirely in Java or Kotlin do not require the NDK. It is only necessary for code written in C or C++, such as games using Unreal Engine or LibGDX, or performance-critical algorithms.
Can I install multiple NDK versions?
Yes. The "Side by side" installation allows you to keep multiple versions (e.g., r25, r26) simultaneously. Each project can specify which version it needs in its build configuration.
Is the NDK free to use?
Yes, the Android NDK is completely free and open-source. There are no licensing fees or subscription costs associated with using it for commercial or personal projects.
Does the NDK work with Visual Studio?
While Android Studio is the primary IDE, you can configure Visual Studio to use the NDK for cross-compilation. However, full debugging and integration are best supported within Android Studio or IntelliJ-based IDEs.
How large is the NDK download?
The size varies by version and included architectures, but typically ranges from 1GB to 2GB per version. Including both x86_64 and arm64 binaries increases the footprint significantly.
Should I update the NDK regularly?
It is good practice to update periodically to get bug fixes and support for newer Android APIs. However, always test your build after an update, as changes in compiler behavior can occasionally break existing code.