Search code examples
androidreact-nativebuildexpo

Expo build failed for android


I'm building a react native app that is using the ble plx library. For that I think it got ejected.

Now I'm trying to publish a internal test in the google play store. I ran the command expo build -p android to create an apk for this purpose and got the error message:

[stderr] FAILURE: Build failed with an exception.

[stderr] * What went wrong:

[stderr] Execution failed for task ':expo-updates:kaptReleaseKotlin'.

[stderr] > A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution

[stderr]    > java.lang.reflect.InvocationTargetException (no error message)

[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] * Get more help at https://help.gradle.org

[stderr] BUILD FAILED in 6m 13s

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.

Use '--warning-mode all' to show the individual deprecation warnings.

See https://docs.gradle.org/6.9/userguide/command_line_interface.html#sec:command_line_warnings

389 actionable tasks: 389 executed

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

Package.json:

{
    "name": "app",
    "version": "0.0.4",
    "scripts": {
        "start": "expo start --dev-client",
        "android": "expo run:android",
        "ios": "expo run:ios",
        "web": "expo start --web",
        "eject": "expo eject",
        "test": "jest --watchAll"
    },
    "jest": {
        "preset": "jest-expo"
    },
    "dependencies": {
        "@config-plugins/react-native-ble-plx": "^0.0.2",
        "@ethersproject/shims": "^5.5.0",
        "@expo/vector-icons": "^12.0.0",
        "@react-native-clipboard/clipboard": "^1.8.5",
        "@react-navigation/bottom-tabs": "^6.2.0",
        "@react-navigation/native": "^6.0.8",
        "@react-navigation/native-stack": "^6.4.1",
        "@reduxjs/toolkit": "^1.7.2",
        "base64-arraybuffer": "^1.0.1",
        "ethers": "^5.5.4",
        "expo": "^44.0.0",
        "expo-asset": "~8.4.6",
        "expo-constants": "~13.0.1",
        "expo-dev-client": "~0.8.4",
        "expo-font": "~10.0.4",
        "expo-linking": "~3.0.0",
        "expo-random": "~12.1.1",
        "expo-secure-store": "~11.1.0",
        "expo-splash-screen": "~0.14.1",
        "expo-status-bar": "~1.2.0",
        "expo-updates": "~0.11.6",
        "expo-web-browser": "~10.1.0",
        "moment": "^2.29.1",
        "react": "17.0.1",
        "react-dom": "17.0.1",
        "react-native": "0.64.3",
        "react-native-ble-plx": "^2.0.3",
        "react-native-elements": "^3.4.2",
        "react-native-gesture-handler": "~2.1.0",
        "react-native-get-random-values": "~1.7.0",
        "react-native-keep-awake": "^4.0.0",
        "react-native-nfc-manager": "^3.13.2",
        "react-native-pager-view": "^6.0.0-rc.1",
        "react-native-paper": "^4.11.2",
        "react-native-reanimated": "~2.3.1",
        "react-native-safe-area-context": "3.3.2",
        "react-native-screens": "~3.10.1",
        "react-native-snackbar": "^2.4.0",
        "react-native-step-indicator": "^1.0.3",
        "react-native-video": "^5.2.0",
        "react-native-web": "0.17.1",
        "react-redux": "^7.2.6"
    },
    "devDependencies": {
        "@babel/core": "^7.12.9",
        "@types/react": "~17.0.21",
        "@types/react-native": "~0.64.12",
        "@types/react-native-keep-awake": "^2.0.3",
        "@types/react-native-video": "^5.0.13",
        "@typescript-eslint/eslint-plugin": "^5.10.2",
        "@typescript-eslint/parser": "^5.10.2",
        "eslint": "^7.32.0",
        "eslint-config-prettier": "^8.3.0",
        "eslint-plugin-import": "^2.25.3",
        "eslint-plugin-node": "^11.1.0",
        "eslint-plugin-prettier": "^4.0.0",
        "eslint-plugin-promise": "^5.2.0",
        "eslint-plugin-react": "^7.27.1",
        "jest-expo": "^44.0.0",
        "json-server": "^0.17.0",
        "prettier": "^2.5.1",
        "typescript": "~4.3.5"
    },
    "private": true
}

I tried to run eas build as well but it failed with the same error. I could guess it's because the app is ejected but I'm not sure how to fix this.

How can I build successfully?


Solution

  • My problem was fixed by adding "image" : "latest" to the eas config. It seems like the jdk used by default has a bug that prevents from building for release.