Search code examples
androidreact-nativeexpoeas

EAS Build (Android) error - Unable to determine the current character, it is not a string, number, array, or object


For my Expo-managed React Native project, I am running eas build on my Windows 10 to create a build for the Google Play Store. Unfortunately, I run into the following error:

[RUN_GRADLEW] FAILURE: Build failed with an exception.
[RUN_GRADLEW] * Where:
[RUN_GRADLEW] Script '/tmp/root/eas-build-local-nodejs/5af39a67-f146-4a89-813c-0ba3b7057662/build/node_modules/@react-native-community/cli-platform-android/native_modules.gradle' line: 450[RUN_GRADLEW] * What went wrong:
[RUN_GRADLEW] A problem occurred evaluating script.
[RUN_GRADLEW] > Calling `[node, /tmp/root/eas-build-local-nodejs/5af39a67-f146-4a89-813c-0ba3b7057662/build/node_modules/@react-native-community/cli/build/bin.js, config]` finished with an exception. Error message: groovy.json.JsonException: Unable to determine the current character, it is not a string, number, array, or object
[RUN_GRADLEW]   
[RUN_GRADLEW]   The current character read is 'i' with an int value of 105
[RUN_GRADLEW]   Unable to determine the current character, it is not a string, number, array, or object
[RUN_GRADLEW]   line number 1
[RUN_GRADLEW]   index number 0
[RUN_GRADLEW]   info Run CLI with --verbose flag for more details.
[RUN_GRADLEW]   ^. Output: info Run CLI with --verbose flag for more details.
[RUN_GRADLEW] * Try:
[RUN_GRADLEW] > Run with --stacktrace option to get the stack trace.
[RUN_GRADLEW] > Run with --info or --debug
[RUN_GRADLEW] option to get more log output.
[RUN_GRADLEW] > Run with --scan to get full insights.
[RUN_GRADLEW] * Get more help at https://help.gradle.org
[RUN_GRADLEW] BUILD FAILED in 27s
[RUN_GRADLEW] Error: Gradle build failed with unknown error. See logs for the "Run gradlew" phase for more information.

I did some research on this issue and the most logical cause seems to be a dependency issue in my package.json. This is what my package.json file looks like:

{
  "scripts": {
    "start": "expo start --dev-client",
    "android": "expo run:android",
    "ios": "expo run:ios",
    "web": "expo start --web",
    "eject": "expo eject",
    "eas-build-pre-install": "npm i"
  },
  "dependencies": {
    "@amplitude/react-native": "^2.12.1",
    "@expo-google-fonts/inter": "^0.2.2",
    "@expo-google-fonts/roboto": "^0.2.3",
    "@expo/config-plugins": "^5.0.4",
    "@expo/prebuild-config": "^5.0.7",
    "@react-native-async-storage/async-storage": "~1.17.3",
    "@react-native-community/datetimepicker": "6.5.2",
    "@react-native-masked-view/masked-view": "0.2.8",
    "@react-navigation/bottom-tabs": "^6.4.0",
    "@react-navigation/native": "^6.0.13",
    "@react-navigation/stack": "^6.3.0",
    "axios": "^0.27.2",
    "dotenv": "^16.0.3",
    "eas-cli": "^2.1.0",
    "eslint": "^8.22.0",
    "eslint-config-rallycoding": "^3.2.0",
    "expo": "~47.0.14",
    "expo-app-loading": "~2.1.0",
    "expo-application": "~5.0.1",
    "expo-auth-session": "~3.8.0",
    "expo-dev-client": "~2.0.1",
    "expo-font": "~11.0.1",
    "expo-image-picker": "~14.0.2",
    "expo-network": "~5.0.0",
    "expo-notifications": "~0.17.0",
    "expo-random": "~13.0.0",
    "expo-splash-screen": "~0.17.5",
    "expo-status-bar": "~1.4.2",
    "expo-updates": "~0.15.6",
    "expo-web-browser": "~12.0.0",
    "firebase": "^9.10.0",
    "lodash": "^4.17.21",
    "moment": "^2.29.4",
    "react": "18.1.0",
    "react-dom": "18.1.0",
    "react-native": "0.70.8",
    "react-native-color-picker": "^0.6.0",
    "react-native-elements": "^3.4.3",
    "react-native-gesture-handler": "~2.8.0",
    "react-native-image-crop-picker": "0.38.1",
    "react-native-image-picker": "^4.8.3",
    "react-native-modal-datetime-picker": "^14.0.0",
    "react-native-open-maps": "^0.4.0",
    "react-native-popup-menu": "^0.16.1",
    "react-native-progress": "^5.0.0",
    "react-native-push-notification": "^8.1.1",
    "react-native-rapi-ui": "^0.2.1",
    "react-native-raw-bottom-sheet": "^2.2.0",
    "react-native-reanimated": "~2.12.0",
    "react-native-safe-area-context": "4.4.1",
    "react-native-screens": "~3.18.0",
    "react-native-searchable-dropdown": "^1.1.3",
    "react-native-svg": "13.4.0",
    "react-native-web": "0.18.9",
    "react-schedule-selector": "^3.0.0",
    "styled-components": "^5.3.5",
    "yelp-fusion": "^3.0.0"
  },
  "devDependencies": {
    "@babel/core": "^7.12.9",
    "react-native-dotenv": "^3.3.1"
  },
  "private": true,
  "name": "<NAME>",
  "version": "0.9.1",
  "description": "<DESCRIPTION>",
  "main": "index.js",
  "repository": {
    "type": "git",
    "url": "<URL>"
  },
  "author": "",
  "license": "ISC",
  "bugs": {
    "url": "<URL>"
  },
  "homepage": "<HOMEPAGE>",
  "type": "commonjs"
}

Currently, I've tried upgrading/downgrading my @react-native-community/datetimepicker and react-native-modal-datetime-picker, since the bug seems to point to the @react-native-community package and only these two packages use that package. However, it doesn't seem to work. I've also tried reinstalling my node_modules to no avail. Currently I'm stuck, and I was wondering if anyone has any other solutions I should look into? Thanks in advance!


Solution

  • It turns out that the culprit was the @amplitude/react-native package at the top of my package.json, which our app wasn't using. Uninstalling it fixed the issue.

    For others coming to this post with similar issues, make sure to clean out any unnecessary packages that your app doesn't use anymore.