EAS build fails for android. reason Deprecated Gradle features were used in this build,

Hey, am having this error when I try to build for android with eas.

[stderr] FAILURE: Build completed with 2 failures.
[stderr] 1: Task failed with an exception.
[stderr] -----------
[stderr] * Where:
[stderr] Build file '/root/workingdir/build/android/app/build.gradle' line: 86
[stderr] * What went wrong:
[stderr] > String index out of range: 0
[stderr] A problem occurred evaluating project ':app'.
[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 29s
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.

Running expo build for aab or apk works fine, but it fails with eas.

I have searched for similar issues but most solutions are on react native not eas.
I am on a managed workflow, and my eas-cli version is 0.46.0.

Update:

I think I should make mention of one of the recommended solutions from the error log i.e compileSdkVersion is not specified. Please add it to build.gradle, if really this is the solution where should I add it please? is it in eas.json.build?

Thanks in advance.

1 Like

Worked like magic.
I followed the guide from the link to run my android build locally, and everything including the gradle was updated, and now works with eas build.

Specifically I used the

expo run:android --variant release

to run my android build locally that did everything for me without any further challenge.
Thanks to the Expo team.

Though I should mention that when you run eas build afterwards, it no longer uses the version of your app as specified in app.config.js/app.json, but you can change the version in android/app/build.gradle

Hi

Yes, expo run:android basically ejects your app, so unless you revert the changes afterwards you are no longer using the managed workflow.

I believe the intention of that troubleshooting documentation is to help you to find what is causing the build errors, rather than just making you eject to the bare workflow. So it’s surprising that your app built after running expo run:android. I would have expected to get some error like you got in your initial message, but with the ability to investigate what was causing the error.

If you have not yet committed the changes made by expo run:android, try cleaning up those changes to get back to the managed workflow and try building again. If you have committed the changes, try reverting to before that commit and see if it builds.

It is complicated. I tried building it locally again and it failed. Then I cloned the project to work on the error, built it locally and the error wasn’t there.
When I tried building it with eas as a managed workflow (after deleting the android directory, metro.config.js basically taking it away from bare workflow) it throws the error. But as a bare workflow, it builds with eas.

My guess is the error showing up or not has to do with the way it was built (talking about local now). But am still running tests on it to see if I can get the error or at least know why it comes and go.

What dependencies do you have in package.json?


  "dependencies": {
    "@aws-amplify/core": "^4.2.7",
    "@expo-google-fonts/lobster": "^0.2.0",
    "@expo-google-fonts/open-sans": "^0.2.0",
    "@expo-google-fonts/roboto-slab": "^0.2.0",
    "@expo-google-fonts/tangerine": "^0.2.0",
    "@react-native-async-storage/async-storage": "^1.15.6",
    "@react-native-community/netinfo": "^6.0.0",
    "@react-navigation/drawer": "^6.1.3",
    "@react-navigation/native": "^6.0.2",
    "@react-navigation/stack": "^6.0.6",
    "aws-amplify": "^4.2.7",
    "expo": "~42.0.1",
    "expo-app-loading": "^1.1.2",
    "expo-application": "~3.2.0",
    "expo-constants": "~11.0.1",
    "expo-device": "~3.3.0",
    "expo-font": "~9.2.1",
    "expo-image-picker": "~10.2.2",
    "expo-linking": "~2.3.1",
    "expo-location": "^12.1.2",
    "expo-notifications": "~0.12.3",
    "expo-secure-store": "~10.2.0",
    "expo-status-bar": "~1.0.4",
    "expo-updates": "~0.8.2",
    "expo-web-browser": "~9.2.0",
    "moment": "^2.29.1",
    "react": "16.13.1",
    "react-dom": "16.13.1",
    "react-native": "https://github.com/expo/react-native/archive/sdk-42.0.0.tar.gz",
    "react-native-elements": "^3.4.2",
    "react-native-extra-dimensions-android": "^1.2.5",
    "react-native-gesture-handler": "^1.10.3",
    "react-native-google-places-autocomplete": "^2.4.1",
    "react-native-maps": "^0.28.0",
    "react-native-material-menu": "^1.2.0",
    "react-native-modal": "^13.0.0",
    "react-native-reanimated": "^2.2.0",
    "react-native-safe-area-context": "3.2.0",
    "react-native-svg": "12.1.1",
    "react-native-web": "~0.13.12",
    "sentry-expo": "^4.0.0",
    "socket.io-client": "^4.1.3"
  },
  "devDependencies": {
    "@babel/core": "^7.9.0"
  }

I created a new Expo SDK 42 app as follows. (I got the version of the blank template from here):

expo init new-app -t blank@42.0.9

EDIT: I have just discovered that you don’t have to figure out the exact version. You can just specify @sdk-42 as the version:

expo init new-app -t blank@sdk-42

I then installed your dependencies. When I tried to build the app it failed, but the error is different to what you got in your first post.

If I run expo doctor I get the following:

% expo doctor
Some dependencies are incompatible with the installed expo package version:
 - @react-native-async-storage/async-storage - expected version: ~1.15.0 - actual version installed: 1.16.1
 - @react-native-community/netinfo - expected version: 6.0.0 - actual version installed: 6.2.1
 - expo-app-loading - expected version: 1.1.2 - actual version installed: 1.3.0
 - react-native-maps - expected version: 0.28.0 - actual version installed: 0.28.1
 - react-native-reanimated - expected version: ~2.2.0 - actual version installed: 2.4.1
Your project may not work correctly until you install the correct versions of the packages.
To install the correct versions of these packages, please run: expo doctor --fix-dependencies,
or install individual packages by running expo install [package-name ...]

You should fix those issues. I ran expo doctor --fix-dependencies, which resulted in the following changes to the dependencies:

diff --git package.json package.json
index 7dec994..ed6dc27 100644
--- package.json
+++ package.json
@@ -15,14 +15,14 @@
     "@expo-google-fonts/open-sans": "^0.2.0",
     "@expo-google-fonts/roboto-slab": "^0.2.0",
     "@expo-google-fonts/tangerine": "^0.2.0",
-    "@react-native-async-storage/async-storage": "^1.15.6",
-    "@react-native-community/netinfo": "^6.0.0",
+    "@react-native-async-storage/async-storage": "~1.15.0",
+    "@react-native-community/netinfo": "6.0.0",
     "@react-navigation/drawer": "^6.1.3",
     "@react-navigation/native": "^6.0.2",
     "@react-navigation/stack": "^6.0.6",
     "aws-amplify": "^4.2.7",
     "expo": "~42.0.1",
-    "expo-app-loading": "^1.1.2",
+    "expo-app-loading": "1.1.2",
     "expo-application": "~3.2.0",
     "expo-constants": "~11.0.1",
     "expo-device": "~3.3.0",
@@ -43,10 +43,10 @@
     "react-native-extra-dimensions-android": "^1.2.5",
     "react-native-gesture-handler": "^1.10.3",
     "react-native-google-places-autocomplete": "^2.4.1",
-    "react-native-maps": "^0.28.0",
+    "react-native-maps": "0.28.0",
     "react-native-material-menu": "^1.2.0",
     "react-native-modal": "^13.0.0",
-    "react-native-reanimated": "^2.2.0",
+    "react-native-reanimated": "~2.2.0",
     "react-native-safe-area-context": "3.2.0",
     "react-native-svg": "12.1.1",
     "react-native-web": "~0.13.12",

After that, the app builds for me. It took quite a long time, though.

1 Like

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