eas cli build android fail with errors

I worked with expo till now, but as my project matured I started with eas cli, still managed expo, SDK version 42.0.0.
I followed closely after the recommended setup and the build work great for my iOS version, but fail when I try to build the Android version.
I get the following error output:

[stderr] FAILURE: Build completed with 2 failures.
[stderr] 1: Task failed with an exception.
[stderr] -----------
[stderr] * Where:
[stderr] Build file '/build/workingdir/build/android/app/build.gradle' line: 86
[stderr] * What went wrong:
[stderr] A problem occurred evaluating project ':app'.
[stderr] > String index out of range: 0
[stderr] * Try:
[stderr] Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
[stderr] ==============================================================================
[stderr] 2: Task failed with an exception.
[stderr] -----------
[stderr] * What went wrong:
[stderr] A problem occurred configuring project ':app'.
[stderr] > compileSdkVersion is not specified. Please add it to build.gradle
[stderr] * Try:
[stderr] Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
[stderr] ==============================================================================
[stderr] * Get more help at https://help.gradle.org
[stderr] BUILD FAILED in 30s
  • Any idea how can I fix it?
  • Is there a way to add stacktrace flag to the eas build?

Thanks

you might try specifing gradleCommand with that flag, but I’m not sure how useful it would be to you

error is in 86 line in your android/app/build.gradle, it should be obvious what the problem is based on that line, if you are not sure please post that section of that file

Thanks for your reply.
I am using the managed expo version, so I don’t have access to the specified file (or do I?)

can you link to the build page?

line 86 is including expo-constants script (unless you are using some third-party config plugins that might modify build.gradle). it’s possible that you are using versions of packages that are not compatible with sdk41

you can reproduce that locally by running (test with latest expo-cli) expo prebuild and building the project from the android studio

Thanks,
my project is private, so cannot provide a link. however, I have can reproduce it on a local build attempt (output bellow)

When I run expo rebuild I get the following in the settings.gradle file:

rootProject.name = '*********'

apply from: '../node_modules/react-native-unimodules/gradle.groovy'
includeUnimodulesProjects()

apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle");
applyNativeModulesSettingsGradle(settings)

include ':app'

sudo eas build --local -p android --profile preview
✔ Linked to project ******
✔ Using remote Android credentials (Expo server)
✔ Using Keystore from configuration: Build Credentials **** (default)
✔ Compressed project files 3s (85.9 MB)
ANDROID_NDK_HOME environment variable was not specified, continuing build without NDK
[SETUP_WORKINGDIR] Preparing workingdir /tmp/eas-build-local-nodejs/e07eef19-49d8-437d-9762-be5770a96d02
[START_BUILD] Starting build
  "job": {
    "type": "managed",
    "platform": "android",
    "projectRootDirectory": ".",
    "projectArchive": {
      "type": "PATH",
      "path": "/tmp/eas-cli-nodejs/203a090d-6a28-4780-85a0-b27ae83bf739.tar.gz"
    },
    "builderEnvironment": {
      "image": "default"
    },
    "cache": {
      "disabled": false,
      "customPaths": [],
      "cacheDefaultPaths": true,
      "clear": false
    },
    "updates": {},
    "username": "*****",
    "buildType": "apk"
  }
[INSTALL_DEPENDENCIES] Running npm in the root dir of your repository
[INSTALL_DEPENDENCIES] npm
[INSTALL_DEPENDENCIES] WARN deprecated deep-assign@3.0.0: Check out `lodash.merge` or `merge-options` instead.
[INSTALL_DEPENDENCIES] npm
[INSTALL_DEPENDENCIES] WARN deprecated babel-preset-es2015@6.24.1: 🙌  Thanks for using Babel: we recommend using babel-preset-env now: please read https://babeljs.io/env to update!
[INSTALL_DEPENDENCIES] npm
[INSTALL_DEPENDENCIES] WARN deprecated @hapi/bourne@1.3.2: This version has been deprecated and is no longer supported or maintained
[INSTALL_DEPENDENCIES] npm WARN deprecated @hapi/topo@3.1.6: This version has been deprecated and is no longer supported or maintained
[INSTALL_DEPENDENCIES] npm
[INSTALL_DEPENDENCIES] WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
[INSTALL_DEPENDENCIES] npm
[INSTALL_DEPENDENCIES] WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
[INSTALL_DEPENDENCIES] npm WARN
[INSTALL_DEPENDENCIES] deprecated sane@4.1.0: some dependency vulnerabilities fixed, support for node < 10 dropped, and newer ECMAScript syntax/features added
[INSTALL_DEPENDENCIES] npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
[INSTALL_DEPENDENCIES] npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
[INSTALL_DEPENDENCIES] npm WARN deprecated @hapi/address@2.1.4: Moved to 'npm install @sideway/address'
[INSTALL_DEPENDENCIES] npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
[INSTALL_DEPENDENCIES] npm WARN
[INSTALL_DEPENDENCIES] deprecated uuid@3.3.2: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
[INSTALL_DEPENDENCIES] npm WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained
[INSTALL_DEPENDENCIES] npm
[INSTALL_DEPENDENCIES] WARN deprecated uglify-es@3.3.9: support for ECMAScript is superseded by `uglify-js` as of v3.13.0
[INSTALL_DEPENDENCIES] npm
[INSTALL_DEPENDENCIES] WARN deprecated @hapi/joi@15.1.1: Switch to 'npm install joi'
[INSTALL_DEPENDENCIES] npm
[INSTALL_DEPENDENCIES] WARN deprecated core-js@1.2.7: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
[INSTALL_DEPENDENCIES] npm
[INSTALL_DEPENDENCIES] WARN deprecated core-js@2.6.12: core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
[INSTALL_DEPENDENCIES] added 1822 packages, and audited 1823 packages in 24s
[INSTALL_DEPENDENCIES] 72 packages are looking for funding
[INSTALL_DEPENDENCIES]   run `npm fund` for details
[INSTALL_DEPENDENCIES] 70 vulnerabilities (6 low, 29 moderate, 32 high, 3 critical)
[INSTALL_DEPENDENCIES]
[INSTALL_DEPENDENCIES] To address issues that do not require attention, run:
[INSTALL_DEPENDENCIES]   npm audit fix
[INSTALL_DEPENDENCIES]
[INSTALL_DEPENDENCIES] To address all issues possible (including breaking changes), run:
[INSTALL_DEPENDENCIES]   npm audit fix --force
[INSTALL_DEPENDENCIES]
[INSTALL_DEPENDENCIES] Some issues need review, and may require choosing
[INSTALL_DEPENDENCIES] a different dependency.
[INSTALL_DEPENDENCIES]
[INSTALL_DEPENDENCIES] Run `npm audit` for details.
[READ_APP_CONFIG] Using app configuration:
[READ_APP_CONFIG] {
  "name": "****",
  "slug": "*****",
  "owner": "****",
  "version": "1.2.0",
  "orientation": "portrait",
  "icon": "./app/assets/icon.png",
  "splash": {
    "image": "./app/assets/icon.png",
    "resizeMode": "contain",
    "backgroundColor": "#00aaff"
  },
  "updates": {
    "fallbackToCacheTimeout": 0
  },
  "assetBundlePatterns": [
    "**/*"
  ],
  "ios": {
    "infoPlist": {
      "NSFaceIDUsageDescription": "This app uses face id to prevent the need to re login too often."
    },
    "supportsTablet": true,
    "bundleIdentifier": "com.***********",
    "googleServicesFile": "./GoogleService-Info.plist",
    "buildNumber": "3"
  },
  "android": {
    "adaptiveIcon": {
      "foregroundImage": "./app/assets/adaptive-icon.png",
      "backgroundColor": "#FFFFFF"
    },
    "package": "com.***********",
    "permissions": [
      "RECEIVE_BOOT_COMPLETED",
      "USE_BIOMETRIC",
      "USE_FINGERPRINT"
    ],
    "versionCode": 21,
    "googleServicesFile": "./google-services.json"
  },
  "web": {
    "favicon": "./app/assets/favicon.png"
  },
  "extra": {
    "bugsnag": {
      "apiKey": "*************"
    }
  },
  "notification": {
    "icon": "./app/assets/notification.png",
    "color": "#00aaff",
    "iosDisplayInForeground": true,
    "androidMode": "collapse",
    "androidCollapsedTitle": "New real time alert in care log"
  },
  "plugins": [
    "sentry-expo",
    [
      "expo-notifications",
      {
        "icon": "./app/assets/notification.png",
        "color": "#00aaff",
        "mode": "production"
      }
    ]
  ],
  "sdkVersion": "42.0.0",
  "platforms": [
    "ios",
    "android",
    "web"
  ],
  "currentFullName": "***********",
  "originalFullName": "**************"
}
[PREBUILD] - Creating native project directories (./ios and ./android) and updating .gitignore
[PREBUILD] Creating native project directories (./ios and ./android) and updating .gitignore
[PREBUILD] - Adding Metro bundler config
[PREBUILD] Adding Metro bundler config
[PREBUILD] - Updating your package.json scripts, dependencies, and main file
[PREBUILD] Updating your package.json scripts, dependencies, and main file
[PREBUILD] [13:31:09] › Removed "main": "node_modules/expo/AppEntry.js" from package.json because we recommend using index.js as main instead
[PREBUILD]
[PREBUILD] [13:31:09] 🧶 Using Yarn to install packages. Pass --npm to use npm instead.
[PREBUILD] - Installing JavaScript dependencies
[PREBUILD] Installing JavaScript dependencies
[PREBUILD] - Config syncing
[PREBUILD] Config syncing
[PREBUILD] yarn install v1.22.15
[PREBUILD] warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[PREBUILD] [1/4] Resolving packages...
[PREBUILD] success Already up-to-date.
[PREBUILD] Done in 0.48s.
[PREPARE_CREDENTIALS] Writing secrets to the project's directory
[CONFIGURE_EXPO_UPDATES] Using default release channel for 'expo-updates' (default)
[RUN_GRADLEW] Running './gradlew :app:assembleRelease' in /tmp/eas-build-local-nodejs/e07eef19-49d8-437d-9762-be5770a96d02/build/android
[RUN_GRADLEW] Downloading https://services.gradle.org/distributions/gradle-6.8-all.zip
[RUN_GRADLEW] Unzipping /var/root/.gradle/wrapper/dists/gradle-6.8-all/9emh0d32e025cam7aasxcw002/gradle-6.8-all.zip to /var/root/.gradle/wrapper/dists/gradle-6.8-all/9emh0d32e025cam7aasxcw002
[RUN_GRADLEW] Set executable permissions for: /var/root/.gradle/wrapper/dists/gradle-6.8-all/9emh0d32e025cam7aasxcw002/gradle-6.8/bin/gradle
[RUN_GRADLEW] Welcome to Gradle 6.8!
[RUN_GRADLEW] Here are the highlights of this release:
[RUN_GRADLEW]  - Faster Kotlin DSL script compilation
[RUN_GRADLEW]  - Vendor selection for Java toolchains
[RUN_GRADLEW] - Convenient execution of tasks in composite builds
[RUN_GRADLEW]  - Consistent dependency resolution
[RUN_GRADLEW] For more details see https://docs.gradle.org/6.8/release-notes.html
[RUN_GRADLEW] Starting a Gradle Daemon (subsequent builds will be faster)
[RUN_GRADLEW] > Configure project :app
[RUN_GRADLEW] Installing unimodules:
[RUN_GRADLEW]  unimodules-core@7.1.2 from /private/tmp/eas-build-local-nodejs/e07eef19-49d8-437d-9762-be5770a96d02/build/node_modules/@unimodules/core
[RUN_GRADLEW]  unimodules-react-native-adapter@6.3.9 from /private/tmp/eas-build-local-nodejs/e07eef19-49d8-437d-9762-be5770a96d02/build/node_modules/@unimodules/react-native-adapter
[RUN_GRADLEW]  expo-application@3.2.0 from /private/tmp/eas-build-local-nodejs/e07eef19-49d8-437d-9762-be5770a96d02/build/node_modules/expo-application
[RUN_GRADLEW]  expo-av@9.2.3 from /private/tmp/eas-build-local-nodejs/e07eef19-49d8-437d-9762-be5770a96d02/build/node_modules/expo-av
[RUN_GRADLEW]  expo-constants@11.0.2 from /private/tmp/eas-build-local-nodejs/e07eef19-49d8-437d-9762-be5770a96d02/build/node_modules/react-native-unimodules/node_modules/expo-constants
[RUN_GRADLEW]  expo-crypto@9.2.0 from /private/tmp/eas-build-local-nodejs/e07eef19-49d8-437d-9762-be5770a96d02/build/node_modules/expo-crypto
[RUN_GRADLEW]  expo-device@3.3.0 from /private/tmp/eas-build-local-nodejs/e07eef19-49d8-437d-9762-be5770a96d02/build/node_modules/expo-device
[RUN_GRADLEW]  expo-error-recovery@2.2.0 from /private/tmp/eas-build-local-nodejs/e07eef19-49d8-437d-9762-be5770a96d02/build/node_modules/expo-error-recovery
[RUN_GRADLEW]  expo-file-system@11.1.3 from /private/tmp/eas-build-local-nodejs/e07eef19-49d8-437d-9762-be5770a96d02/build/node_modules/expo-file-system
[RUN_GRADLEW]  expo-firebase-analytics@4.1.0 from /private/tmp/eas-build-local-nodejs/e07eef19-49d8-437d-9762-be5770a96d02/build/node_modules/expo-firebase-analytics
[RUN_GRADLEW]  expo-firebase-core@3.1.0 from /private/tmp/eas-build-local-nodejs/e07eef19-49d8-437d-9762-be5770a96d02/build/node_modules/expo-firebase-core
[RUN_GRADLEW]  expo-font@9.2.1 from /private/tmp/eas-build-local-nodejs/e07eef19-49d8-437d-9762-be5770a96d02/build/node_modules/expo-font
[RUN_GRADLEW]  expo-image-loader@2.2.0 from /private/tmp/eas-build-local-nodejs/e07eef19-49d8-437d-9762-be5770a96d02/build/node_modules/expo-image-loader
[RUN_GRADLEW]  expo-keep-awake@9.2.0 from /private/tmp/eas-build-local-nodejs/e07eef19-49d8-437d-9762-be5770a96d02/build/node_modules/expo-keep-awake
[RUN_GRADLEW]  expo-local-authentication@11.1.1 from /private/tmp/eas-build-local-nodejs/e07eef19-49d8-437d-9762-be5770a96d02/build/node_modules/expo-local-authentication
[RUN_GRADLEW]  expo-modules-core@0.2.0 from /private/tmp/eas-build-local-nodejs/e07eef19-49d8-437d-9762-be5770a96d02/build/node_modules/expo-modules-core
[RUN_GRADLEW]  expo-notifications@0.12.3 from /private/tmp/eas-build-local-nodejs/e07eef19-49d8-437d-9762-be5770a96d02/build/node_modules/expo-notifications
[RUN_GRADLEW]  expo-secure-store@10.2.0 from /private/tmp/eas-build-local-nodejs/e07eef19-49d8-437d-9762-be5770a96d02/build/node_modules/expo-secure-store
[RUN_GRADLEW]  expo-splash-screen@0.11.4 from /private/tmp/eas-build-local-nodejs/e07eef19-49d8-437d-9762-be5770a96d02/build/node_modules/expo-splash-screen
[RUN_GRADLEW]  expo-structured-headers@1.1.1 from /private/tmp/eas-build-local-nodejs/e07eef19-49d8-437d-9762-be5770a96d02/build/node_modules/expo-structured-headers
[RUN_GRADLEW]  expo-updates-interface@0.2.2 from /private/tmp/eas-build-local-nodejs/e07eef19-49d8-437d-9762-be5770a96d02/build/node_modules/expo-updates-interface
[RUN_GRADLEW]  expo-updates@0.8.5 from /private/tmp/eas-build-local-nodejs/e07eef19-49d8-437d-9762-be5770a96d02/build/node_modules/expo-updates
[RUN_GRADLEW]  unimodules-app-loader@2.2.0 from /private/tmp/eas-build-local-nodejs/e07eef19-49d8-437d-9762-be5770a96d02/build/node_modules/unimodules-app-loader
[RUN_GRADLEW]  unimodules-task-manager-interface@6.2.0 from /private/tmp/eas-build-local-nodejs/e07eef19-49d8-437d-9762-be5770a96d02/build/node_modules/unimodules-task-manager-interface
[RUN_GRADLEW] Found some duplicated unimodule packages. Installed the ones with the highest version number.
[RUN_GRADLEW] Make sure following dependencies of your project are resolving to one specific version:
[RUN_GRADLEW]  expo-constants
[RUN_GRADLEW] FAILURE: Build failed with an exception.
[RUN_GRADLEW] * What went wrong:
[RUN_GRADLEW] A problem occurred configuring project ':app'.
[RUN_GRADLEW] > SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at '/private/tmp/eas-build-local-nodejs/e07eef19-49d8-437d-9762-be5770a96d02/build/android/local.properties'.
[RUN_GRADLEW] * Try:
[RUN_GRADLEW] Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
[RUN_GRADLEW] * Get more help at
[RUN_GRADLEW] https://help.gradle.org
[RUN_GRADLEW] BUILD FAILED in 2m 26s
[RUN_GRADLEW] Error: Gradle build failed with unknown error. Please see logs for the "Run gradlew" phase.

Build failed
Gradle build failed with unknown error. Please see logs for the "Run gradlew" phase.

OK, but the error was about:

What does that file contain? Especially around line 86.

Also, your local build log contains this:

You should decide whether you want to use npm or yarn to install your dependencies.

If you use npm:

  • delete yarn.lock
  • delete node_modules
  • run npm install

If you use yarn:

  • delete package-lock.json
  • delete node_modules
  • run yarn

Then try your build again and send post the errors, if any.

I was using only npm - the yarn is used by eas regardless of my decision. The funny thing is that expo cli is using npm…

Your suggestion to delete the node_modules was helpful.
For those who see this thread:

  1. Delete you node modules folder.
  2. I decided to build with yarn and not npm so it will align with eas build.
  3. eas build
    Looks like it is working now.

Thanks @wodin

1 Like

eas build will use npm if it only finds package-lock.json and it will use yarn if it only finds yarn.lock. If it finds both files it complains and uses yarn.

I had no yarn installed and no yarn lock file in my system / git and eas build was definitely used yarn, even though the only lock file was created by npm.
I am shifting my project to yarn now, but I think it is a bug.

Strange. And your package-lock.json is/was checked in to Git? And not in your .gitignore file?

I see this from your build logs:

So somehow it was using both.