Search code examples
androidreact-nativebuildexpoexpo-image-picker

How can I fix the Execution failed for task ':expo-image-picker:compileReleaseKotlin' error in react-native Expo android build?


Execution failed for task ':expo-image-picker:compileReleaseKotlin'.

I am a beginner in react-native and it is my first project which I'm trying to build.

But on building i receive following errors:

FAILURE: Build completed with 2 failures.
[stderr] 
1: Task failed with an exception.
[stderr] 
-----------
[stderr] 
* What went wrong:
[stderr] 
Execution failed for task ':expo-image-picker:compileReleaseKotlin'.
[stderr] 
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
[stderr] 
   > Compilation error. See log for more details
[stderr] 
* Try:
[stderr] 
> Run with --stacktrace option to get the stack trace.
[stderr] 
> Run with --info or --debug option to get more log output.
[stderr] 
> Run with --scan to get full insights.
[stderr] 
==============================================================================
[stderr] 
2: Task failed with an exception.
[stderr] 
-----------
[stderr] 
* What went wrong:
[stderr] 
java.lang.StackOverflowError (no error message)
[stderr] 
* Try:
[stderr] 
> Run with --stacktrace option to get the stack trace.
[stderr] 
> Run with --info or --debug option to get more log output.
[stderr] 
> Run with --scan to get full insights.
[stderr] 
==============================================================================
[stderr] 
* Get more help at https://help.gradle.org
[stderr] 
BUILD FAILED in 8m 3s
Error: Gradle build failed with unknown error. See logs for the "Run gradlew" phase for more information.

I am struggling with this error for second week and can't find any solution to fix it.

As I understand, i may be wrong, but this issues comes because of the dependencies incapability.

my package.json:

{
    "name": "alarm-agent-app",
    "version": "1.0.0",
    "main": "node_modules/expo/AppEntry.js",
    "scripts": {
        "start": "expo start",
        "android": "expo start --android",
        "ios": "expo start --ios",
        "web": "expo start --web",
        "eject": "expo eject",
        "lint": "eslint \"src/**/*.{js, jsx}\"",
        "format:check": "prettier --check .",
        "format": "prettier --write .",
        "postinstall": "patch-package"
    },
    "dependencies": {
        "@expo/config-plugins": "~6.0.0",
        "@expo/prebuild-config": "~6.0.0",
        "@gorhom/bottom-sheet": "4",
        "@react-native-async-storage/async-storage": "1.17.11",
        "@react-native-community/netinfo": "9.3.7",
        "@react-native-picker/picker": "2.4.8",
        "@react-navigation/material-bottom-tabs": "^6.2.1",
        "@react-navigation/native": "^6.0.10",
        "@react-navigation/native-stack": "^6.6.2",
        "@reduxjs/toolkit": "^1.8.3",
        "axios": "^0.27.2",
        "expo": "^48.0.11",
        "expo-app-loading": "^2.1.1",
        "expo-av": "~13.2.1",
        "expo-background-fetch": "~11.1.1",
        "expo-build-properties": "~0.6.0",
        "expo-checkbox": "~2.3.1",
        "expo-dev-client": "~2.2.1",
        "expo-font": "~11.1.1",
        "expo-image": "~1.0.0",
        "expo-image-manipulator": "~11.1.1",
        "expo-image-picker": "^14.1.1",
        "expo-linear-gradient": "~12.1.2",
        "expo-location": "~15.1.1",
        "expo-secure-store": "~12.1.1",
        "expo-status-bar": "~1.4.4",
        "expo-task-manager": "~11.1.1",
        "expo-updates": "~0.16.4",
        "formik": "^2.2.9",
        "global": "^4.4.0",
        "moment": "^2.29.3",
        "patch-package": "^7.0.0",
        "postinstall-postinstall": "^2.1.0",
        "react": "18.2.0",
        "react-dom": "18.2.0",
        "react-native": "0.71.8",
        "react-native-gesture-handler": "~2.9.0",
        "react-native-maps": "1.3.2",
        "react-native-maps-directions": "^1.9.0",
        "react-native-paper": "^4.12.2",
        "react-native-reanimated": "~2.14.4",
        "react-native-redash": "^18.1.0",
        "react-native-safe-area-context": "4.5.0",
        "react-native-screens": "~3.20.0",
        "react-native-svg": "13.4.0",
        "react-native-toast-message": "2.1.5",
        "react-native-vector-icons": "^9.2.0",
        "react-native-web": "~0.18.11",
        "react-redux": "^8.0.2",
        "socket.io-client": "^4.5.1",
        "yup": "^1.0.2"
    },
    "devDependencies": {
        "@babel/core": "^7.20.0",
        "@babel/preset-env": "^7.1.6",
        "eslint": "^8.39.0",
        "eslint-config-prettier": "^8.8.0",
        "eslint-plugin-prettier": "^4.2.1",
        "eslint-plugin-react": "^7.32.2",
        "eslint-plugin-react-hooks": "^4.6.0",
        "eslint-plugin-react-native": "^4.0.0",
        "prettier": "2.8.8"
    },
    "resolutions": {
        "@expo/config-plugins": "~6.0.0",
        "@expo/prebuild-config": "~6.0.0",
        "expo-modules-autolinking": "~1.1.0"
    },
    "private": true
}

Will be so happy and grateful for any help and info

I tried to google, ask chat-gpt and also follow the guide which i found here: https://github.com/expo/expo/issues/15629, but still same errors


Solution

  • Its not the best solution, but just downgrading to 14.0.0 fixed the problem.