Expo eas: Android build fails if I run a prebuild before

4.7k Views Asked by At

I use Expo 46.

I would like to change some config in my AndroidManifest so I run an npx expo prebuild that generates an android folder without error.

But then my eas build is not working anymore (it is if I don't run prebuild).
I get this error:

Failed to find 'build.gradle' file for project: /home/expo/workingdir/build/android/app.

Am I missing something?

2

There are 2 best solutions below

3
On

Try running the expo prebuild command with the --clear flag, which will clear any existing pre-build files before generating the new ones.

This should ensure that the generated android folder includes the build.gradle file, and the eas build command should be able to use this file to build the app.

npx expo prebuild --clean

Alternatively, you can try running the eas build command without running the expo prebuild command first. This will use the original Android project files in your app, which should include the build.gradle file and allow the eas build command to work correctly.

How to run the eas build command without running expo prebuild first:

npx eas build
3
On

Run the npx expo-updates in the root of your project in order to update the build.gradle file with the necessary changes.

By the way, as I saw your remarks under the other posts: The expo prebuild command generates an Android project in the android directory, which contains the build.gradle file that is used by the expo build:android command. The eas build command is a shorthand for the expo build:android command, so it expects the Android project to be present in the android directory.

If you run expo prebuild and then eas build, the eas build command should be able to find the build.gradle file and build the Android app successfully.