React Native "SDK location not found" (local.properties) in CI
The Android Gradle build resolves the SDK path from ANDROID_HOME/ANDROID_SDK_ROOT or android/local.properties sdk.dir. In CI, local.properties is gitignored and the env var may be unset, so Gradle reports the SDK location is not found.
What this error means
The Android build fails early with "SDK location not found. Define a valid SDK location with an ANDROID_HOME environment variable or by setting the sdk.dir path in your project's local.properties file".
* What went wrong:
A problem occurred configuring project ':app'.
> SDK location not found. Define a valid SDK location with an ANDROID_HOME
environment variable or by setting the sdk.dir path in your project's
local.properties file at '/home/runner/work/app/app/android/local.properties'.Common causes
local.properties is not committed
android/local.properties is correctly gitignored, so a CI checkout has no sdk.dir.
ANDROID_HOME / ANDROID_SDK_ROOT unset
No env var points at the SDK, so Gradle has no fallback to locate it.
How to fix it
Export ANDROID_SDK_ROOT in CI
Provision the SDK and set the env var so Gradle finds it without local.properties.
- uses: android-actions/setup-android@v3
- run: echo "ANDROID_HOME=$ANDROID_SDK_ROOT" >> "$GITHUB_ENV"Generate local.properties in the build step
Write sdk.dir from the env var before invoking Gradle.
echo "sdk.dir=$ANDROID_SDK_ROOT" > android/local.propertiesHow to prevent it
- Provision the Android SDK and export ANDROID_SDK_ROOT in CI.
- Never commit local.properties; generate it in the pipeline.
- Cache the SDK to avoid re-provisioning each run.