SDK location not found. Define a valid SDK location with an ANDROID_HOME environment variable

Trying to run eas build locally on Windows.
Windows 11
Ubuntu on WSL2 version "22.04.1 LTS
Android Studio 2022.2.1

When I run
npx cross-env APP_ENV=(myENV) eas build --platform android --profile (MyProfile) --local

I get the following Error:

[RUN_GRADLEW] FAILURE: Build completed with 2 failures.
[RUN_GRADLEW] 1: Task failed with an exception.
[RUN_GRADLEW] -----------
[RUN_GRADLEW] * Where:
[RUN_GRADLEW] Script '/tmp/root/eas-build-local-nodejs/6d8cfb3f-be62-4184-a5a3-4fda5c887d0b/build/node_modules/expo-modules-autolinking/scripts/android/autolinking_implementation.gradle' line: 272
[RUN_GRADLEW] * What went wrong:
[RUN_GRADLEW] A problem occurred evaluating project ':expo'.
[RUN_GRADLEW] > A problem occurred configuring project ':expo-modules-core'.
[RUN_GRADLEW]    > Failed to notify project evaluation listener.
[RUN_GRADLEW]       >
[RUN_GRADLEW] 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 '/tmp/root/eas-build-local-nodejs/6d8cfb3f-be62-4184-a5a3-4fda5c887d0b/build/android/local.properties'.
[RUN_GRADLEW]       > Could not get unknown property 'release' for SoftwareComponentInternal set of type org.gradle.api.internal.component.DefaultSoftwareComponentContainer.
[RUN_GRADLEW] * Try:
[RUN_GRADLEW] > Run with --stacktrace option to get the stack trace.
[RUN_GRADLEW] > Run with --info or --debug option to get more log output.
[RUN_GRADLEW] > Run with --scan to get full insights.
[RUN_GRADLEW] ==============================================================================
[RUN_GRADLEW] 2: Task failed with an exception.
[RUN_GRADLEW] -----------
[RUN_GRADLEW] * What went wrong:
[RUN_GRADLEW] A problem occurred configuring project ':expo'.
[RUN_GRADLEW] > compileSdkVersion is not specified. Please add it to build.gradle
[RUN_GRADLEW] * Try:
[RUN_GRADLEW] > Run with --stacktrace option to get the stack trace.
[RUN_GRADLEW] > Run with --info or --debug option to get more log output.
[RUN_GRADLEW] > Run with --scan to get full insights.
[RUN_GRADLEW] ==============================================================================
[RUN_GRADLEW] * Get more help at https://help.gradle.org
[RUN_GRADLEW] BUILD FAILED in 15s

I tried adding ANDROID_HOME to my build profile vars, but it didn’t change anything.
My eas.json:

{
  "cli": {
    "version": ">= 3.1.1",
    "promptToConfigurePushNotifications": false
  },

  "build": {
    "myProfile": {
      "channel": "production",
      "ios": {
        "resourceClass": "m-medium"
      },
      "env": {
        "APP_ENV": "myEnv",
        "ANDROID_SDK_ROOT": "C\\:\\Users\\SysAdmin\\AppData\\Local\\Android\\Sdk",
        "ANDROID_HOME": "C\\:\\Users\\SysAdmin\\AppData\\Local\\Android\\Sdk"
      }
    },
  },
  "submit": {
    "production": {}
  }
}

I even tried adding an android => local.properties file with:

sdk.dir = C\:\\Users\\SysAdmin\\AppData\\Local\\Android\\sdk
ANDROID_HOME = C\:\\Users\\SysAdmin\\AppData\\Local\\Android\\sdk

I don’t know what else to try. Any help would be appreciated.

Turns out the problem was a console.log in my app.config.js. Removing it solved the problem. This is only an issue with SDK47 and before. It’s fixed in SDK48

1 Like

Hi @7samurai

I’m glad you figured it out :slight_smile:

Fyi, since you’re running on Ubuntu (even if on WSL2), you don’t need npx cross-env. You can just use the following:

APP_ENV=(myENV) eas build --platform android --profile (MyProfile) --local

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.