I have downloaded AOSP, but I don't know how to compile android shell program, like dex2oat, which can be run in Ubuntu.
how to compile dex2oat which can run in ubuntu
922 views Asked by Blueke.Zhou AtThere are 2 answers
Tools compiled for Android are usually going to be compiled for a different architecture (ARM instead of x86) and will often rely on different versions of system libraries. You may need to make changes to the source code and the associated build options to port something from Android to your host machine, which may prove to be a long, but definitely not impossible task.
My suggestion is to look for a version for your host that's been made by someone already - and if that doesn't help, point to your standard linux compiler (probably defined somewhere in your environment variables if you've built aosp), try running make, and fix the errors you get one by one. Good times
That said: you can find a bunch of Android tools pre-compiled for your host machine in out/host/linux-x86/bin/, including dex2oat.
dex2oat requires detail knowledge of the system installed on a particular target device, hence running it on a development system is generally not meaningful.
The exception would be running it as part of a build of Android itself, for example from AOSP sources. In that case a working build of the tool will be created, and utilized by pointing it at the relevant details of what will be installed on the targeted device.
tl;dr dex2oat is meaningless without the context of the device; the situation where running it on the development machine rather than the Android device is potentially useful is already handled by the AOSP build system.