如何单独编译Android模拟器中的android-emugl模块
android-emugl Module Separately in the Android Emulator Codebase Hey there! Let’s walk through exactly how to compile the android-emugl module on its own—no need to build the entire Android codebase. Here’s what you need to do:
Prerequisites
First, make sure you’ve already set up your Android source code environment:
- You’ve run
repo syncto pull the full emulator codebase - You’re working from the root directory of your Android source tree
Step-by-Step Build Process
Load the build environment scripts
Open your terminal and run this command to initialize the Android build system:source build/envsetup.shThis sets up all the necessary environment variables and helper commands you’ll need for building.
Select your target device configuration (optional but recommended)
Even though we’re building a single module, specifying a target ensures the build uses the right architecture and settings for the emulator. Run:lunchThen pick a target like
sdk_phone_x86_64(for 64-bit x86 emulators) or another emulator-compatible option from the list.Compile the
android-emuglmodule
You have two easy ways to do this:- Option 1: Build from the module directory
Navigate to theandroid-emugldirectory first:
Then run thecd hardware/google/emugl/mmcommand (which builds all modules in the current directory):mm - Option 2: Build directly from the source root
If you don’t want to change directories, use themmmcommand followed by the module’s path:mmm hardware/google/emugl/
- Option 1: Build from the module directory
What Happens Next?
Once the build finishes successfully, you’ll find the compiled binaries and libraries in the out/target/product/<your-target>/obj/lib/ and out/target/product/<your-target>/system/lib/ directories (the exact location depends on the submodules within emugl).
Troubleshooting Tips
- If you hit dependency errors, try running
make cleanin theemugldirectory first, then re-run the build command. - For first-time builds, it’s normal to wait a bit longer as the system pulls and compiles any missing dependencies.
内容的提问来源于stack exchange,提问作者Michel Roger

