EAS Build fails in step "Run gradle"

  1. SDK Version: 45
  2. Platforms(Android/iOS/web/all): Android
  3. Add the appropriate “Tag” based on what Expo library you have a question on.
  4. Node Version: 16.19.0
  5. Npm Version: 8.19.3
  6. Expo Version: 6.1.0
  7. Eas-Cli Version: 3.3.1

When I build the app by running the ‘eas build --local’ command selecting Android, at build time it fails with the following error:
[RUN_GRADLEW] gradlew: 154: Syntax error: “(” unexpected
[RUN_GRADLEW] Error: Gradle build failed with unknown error. See logs for the “Run gradlew” phase for more information.

  • eas.json
    {
    “cli”: {
    “version”: “>= 3.3.1”
    },
    “build”: {
    “preview”: {
    “android”: {
    “buildType”: “apk”
    }
    },
    “preview2”: {
    “android”: {
    “gradleCommand”: “:app:assembleRelease”
    }
    },
    “development”: {
    “developmentClient”: true,
    “distribution”: “internal”
    },
    “production”: {}
    }
    }

  • gradlew

function sth()

this is a bash syntax, but gradlew is executed with with sh (bourne shell)

Also you shouldn’t modify that file with your own customization, they file is updated when you update gradle, so your changes will get overridden.

I didn’t edit this file. I’m trying to migrate my app to EAS and I can generate the .apk with expo command but I’cant with eas build command.

Old gradle could have bash scripts, but you shouldn’t use those versions, especially if you are on sdk45. Most likelly you have that old file for a while and it never go updated. You can run ./gradlew wrapper, it should update gradlew script to be inline with your gradle wrapper version.

Do you mean expo build:android?

If so, I believe that would have built the app as if it were a managed app, but you seem to have an android directory, making it a bare app. Could you clarify?

If the app is supposed to be using the managed workflow, you should probably get rid of the android directory (and ios if you have it.) But of course if you have made changes in the native projects you might not be able to just delete them… but if that’s the case, then expo build:android would not have worked for you.

See also: https://expo.fyi/prebuild-cleanup

When I execute this command ‘./gradlew wrapper’ in android file this is the error:
Could not read script ‘${App_directory}/app/node_modules/react-native-unimodules/gradle.groovy’ as it does not exist.
So I install this deprecated dependency and run ./gradlew wrapper again and see this:

FAILURE: Build failed with an exception.
Where Build file ‘${App_directory}/app/node_modules/expo-application/android/build.gradle’ line: 48
What went wrong:
A problem occurred configuring project ‘:expo-application’.
Exception thrown while executing model rule: PublishingPluginRules#publishing(ExtensionContainer)
Could not get unknown property ‘release’ for SoftwareComponentInternal set of type org.gradle.api.internal.component.DefaultSoftwareComponentContainer.
Deprecated Gradle features were used in this build, making it compatible with Gradle 5.0.

Yeah, I mean expo build:android.
This is the folder structure of the project


I need to generate the bundle with EAS.

OK, why are you doing that? :slight_smile:

If you were using expo build:android before, then I suggest you rename android to android.bak and try building with eas build -p android --profile ...
If that works, then delete android.bak. Same for ios.

I see you also have both package-lock.json and yarn.lock. You should pick either npm or yarn to manage your dependencies. You should not use both.

If you’re using yarn, delete package-lock.json.
If you’re using npm, delete yarn.lock.

Finally I was able to create the apk and the aab. Thanks for everything guys.
The steps I followed were:

  • Rename ‘android’ file to ‘android.bak’.
  • Run ‘eas build -p android --profile preview’ for apk.

Great :slight_smile: I’m glad you got it working. You should do the same for the ios directory. And probably delete them. And you should still get rid of one of the lock files if you have not yet done so.

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