Error while build android

Hey, today I coded an app using react-native and expo.

I aleready builded an version of the app but now i can’t build anymore.

When I run: expo prebuild I become the following response:

$ expo-cli prebuild

This command is being executed with the global Expo CLI. Learn more: https://blog.expo.dev/the-new-expo-cli-f4250d8e3421
To use the local CLI instead (recommended in SDK 46 and higher), run:
› npx expo prebuild

√ The android project is malformed, would you like to clear the project files and reinitialize them? ... yes
✔ Cleared android code
✔ Created native project | gitignore already synced
✔ Updated package.json and added index.js entry point for iOS and Android
📦 Using npm to install packages.
✔ Cleaned JavaScript dependencies 11577ms
✔ Installed JavaScript dependencies 79258ms
✖ Config sync failed
[android.dangerous]: withAndroidDangerousBaseMod: Project file "MainApplication" does not exist in android project for root "W:\Workspace\[GitHub]\lvckyencrypt-v3"

When I try to run expo build:android I become a response from “Running gradle” with the following response:

[stderr] /root/.gradle/caches/transforms-3/933b1f5f2047e9e20e4541e989803929/transformed/material-1.5.0/res/values/values.xml:238:4: Invalid <color> for given resource value.
> Task :app:processReleaseMainManifest
/app/turtle/workingdir/android/sdk46/android-shell-app/app/src/main/AndroidManifest.xml:134:5-139:39 Warning:
	activity#com.facebook.FacebookActivity@android:theme was tagged at AndroidManifest.xml:134 to replace other declarations but no other declaration present
/app/turtle/workingdir/android/sdk46/android-shell-app/app/src/main/AndroidManifest.xml:23:9-32:20 Warning:
	provider#expo.modules.filesystem.FileSystemFileProvider@android:authorities was tagged at AndroidManifest.xml:23 to replace other declarations but no other declaration present
> Task :app:processReleaseManifest
> Task :app:processReleaseManifestForPackage
> Task :app:processReleaseJavaRes NO-SOURCE
> Task :app:mergeReleaseShaders
> Task :app:compileReleaseShaders NO-SOURCE
> Task :app:generateReleaseAssets UP-TO-DATE
> Task :app:mergeReleaseNativeLibs
> Task :app:mergeReleaseAssets
> Task :app:stripReleaseDebugSymbols
> Task :app:mergeReleaseArtProfile
> Task :app:compressReleaseAssets
> Task :app:collectReleaseDependencies
> Task :app:mergeReleaseResources FAILED
> Task :app:sdkReleaseDependencyData
> Task :app:validateSigningRelease
> Task :app:extractReleaseNativeSymbolTables
> Task :expo:compileReleaseKotlin
[stderr] FAILURE: Build failed with an exception.
[stderr] * What went wrong:
[stderr] Execution failed for task ':app:mergeReleaseResources'.
[stderr] > A failure occurred while executing com.android.build.gradle.internal.res.ResourceCompilerRunnable
[stderr]    > Resource compilation failed. Check logs for 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] * Get more help at https://help.gradle.org
[stderr] BUILD FAILED in 38s
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.3.3/userguide/command_line_interface.html#sec:command_line_warnings
45 actionable tasks: 45 executed
Unable to list file systems to check whether they can be watched. The whole state of the virtual file system has been discarded. Reason: Could not query file systems: could not open mount file (errno 2: No such file or directory)
Error: ./gradlew exited with non-zero code: 1
    at ChildProcess.completionListener (/app/turtle/node_modules/@expo/xdl/node_modules/@expo/spawn-async/build/spawnAsync.js:52:23)
    at Object.onceWrapper (events.js:482:26)
    at ChildProcess.emit (events.js:375:28)
    at ChildProcess.emit (domain.js:470:12)
    at maybeClose (internal/child_process.js:1055:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
    ...
    at spawnAsync (/app/turtle/node_modules/@expo/xdl/node_modules/@expo/spawn-async/build/spawnAsync.js:17:21)
    at spawnAsyncThrowError (/app/turtle/node_modules/@expo/xdl/build/detach/ExponentTools.js:201:45)
    at buildShellAppAsync (/app/turtle/node_modules/@expo/xdl/build/detach/AndroidShellApp.js:986:11)
    at async Object.createAndroidShellAppAsync (/app/turtle/node_modules/@expo/xdl/build/detach/AndroidShellApp.js:397:5)
    at async runShellAppBuilder (/app/turtle/build/builders/android.js:102:9)
    at async Object.buildAndroid [as android] (/app/turtle/build/builders/android.js:50:28)
    at async build (/app/turtle/build/jobManager.js:181:33)
    at async processJob (/app/turtle/build/jobManager.js:118:32)
    at async Object.doJob (/app/turtle/build/jobManager.js:49:5)
    at async main (/app/turtle/build/server.js:66:13)

After 3 hours of Googleing I don’t know what I have to do.
Can someone help me out please?

Kind Regards
Iven | LvckyAPI

Hi @lvckyapi

There are a few things that are potentially wrong. It seems you are trying to use expo prebuid along with expo build:android, but these do not go together. Also, you are using expo-cli ... instead of npx expo ... in an Expo SDK 46 project. From SDK 46 you should be using npx expo ...

expo build:android is the old build system. It still works for now, but will be shut down soon.

npx expo prebuild is part of the new build system. For a managed workflow app (i.e. an app that does not have an android directory), the EAS Build build server will automatically run eas build for you to generate the native code.

If you need to install a dependency that includes native code that is not part of the Expo SDK, then previously you would have had to eject. These days, you can install the dependency in the managed workflow and use a config plugin if necessary to make any changes to the native projects that might be needed to integrate the dependency. Config plugins are run during the “prebuild”. But as I mentioned above, if you do not have an android directory in your app then the prebuild will be done automatically on the EAS Build server when you build.

Maybe you want to install a dependency that needs changes to the native project, but there is no config plugin written for it yet and you do not want to write one yourself. In that case you could run npx expo prebuild, which will generate the native project. At this point you are basically on the “bare” workflow and you would need to follow the “bare workflow” instructions in the Expo docs when you want to install new dependencies etc. Also, if you want to change things like your app icon or splash screen or other stuff in app.json, you would need to make the changes manually in the native project.

i.e. since you have run expo prebuild, you have the native android directory and you are effectively on the “bare” workflow.

If you did not intend to switch to the bare workflow, you might want to switch back to the managed workflow. This basically involves getting rid of the android / ios directories. See also expo.fyi/prebuild-cleanup.

However, there seems to be something wrong with the prebuild process, so the above might not be enough to fix things. If you did intend to run the prebuild to generate the native android project, then maybe npx expo prebuild --clean will get things working for you, but I doubt it. (Also, bear in mind that the --clean option will wipe out the native projects and regenerate them, so if there are any changes there that you need to keep, you would need to re-apply them after running the prebuild.)

I suggest you check what changes were made to app.json (or app.config.js etc.) recently to see what might have caused the prebuild process to break. Also, I suggest you cleanup the changes from running npx expo prebuild (or npx expo run:android) unless you intended to switch away from the managed workflow.

Also, if you are deliberately using npx expo prebuild, then expo build:android will not work for you. But since expo build:android is going away soon, you should switch to eas build -p android anyway.

You should probably also run expo-cli doctor and npx expo install --check to see if they complain about anything.

I delete the whole project an created a new one.
Then I put my old code in there.

The build with eas build -p android --profile preview is successfull fot building a APK.
But there is another problem now.

Once I installed the App on my physical device, the app launces the splash screen and crash without any reasen instantly after I can see the Splashscreen.

Please Help

Have a look at this page: Debugging - Expo Documentation

In particular, this part:

Hint: Sometimes, running your app in “production mode” locally will show errors that normally wouldn’t be thrown. You can run an app locally in production by running npx expo start --no-dev --minify. “–no-dev” tells the server not to be run in development mode, and “–minify” will minify your code the same way it is for production JavaScript bundles.

but the rest of the page might help too.

If you’re still stuck, try this: fyi/manual-debugging.md at main · expo/fyi · GitHub

Thanks for your help.
But this does’nt help me.

I runned this with your example without any error but if I build the App to an apk to install it an my real physical android device the App still crashing randomly.

I attached an Video of my error:
https://youtu.be/xzFsEWIeMwI

Please get the device logs (adb logcat) and search for errors (probably “FATAL”).