Is deleting /system/bin/dex2oat file safe? I was looking into a couple of Android tombstones files of an old Samsung phone running Marshmallow. Found a crash in every single one with the same culprit, dex2oat.

From my limited understanding it is a Compiler that takes arguments from Android Runtime and convert dex files to  Android optimised ones in oat format.

I ran into the same issue even if I factory reset or freezing a lot of apps. I have this device rooted and decided to take a risky step. I backed up first and deleted dex2oat from /system/bin. Then I rebooted system with risk of bricking it.

So far it is working fine.

Due my lack of understanding I don't know how crucial is this dex2oat to system stability and I want to know what is the impact on it.
Runtime is an environment in which programs written in a specific language run. Android Runtime (ART) is Java-like runtime which runs Dalvik Executable (DEX) bytecode (from apk files) in a Virtual Machine. Like other Runtime Environments ART can run the code in three different modes:


Interpretation
Just-in-Time (JIT) compilation
Ahead of Time (AOT) compilation


In order to improve performance, JIT and AOT compilers translate DEX bytecode (during or before execution respectively) into native machine language. JIT compiler was part of DVM, readded to ART in Android 7. Since then AOT compiler also supports profile-guided background compilation. App profiles are created during JIT compiled executions.

While interpreter is part of ART libraries, dex2oat tool is used as JIT and AOT compiler. Documentation states:


  At install time, ART compiles apps using the on-device dex2oat tool. This utility accepts DEX files as input and generates a compiled app executable for the target device. 


And here:


  JIT and AOT use the same compiler with a similar set of optimizations


On your Marshmallow ROM AOT compilation won't work in the absence of dex2oat which may adversely affect the apps performance. Also the installd native service and PackageManager Java service rely on dex2oat during app installation or profile updation of previously installed apps. So they may break due to missing file.

To summarize, installd or dex2oat crashes are serious bugs in your ROM which need to be fixed. Deleting dex2oat binary isn't a solution but a workaround which is very likely to fail.



RELATED:


What is needed to run ELF binaries compiled from android APKs?