Android simulator download, compile and debug

Source: Internet
Author: User

Android Simulator Source Download

The download of the source code of Android Simulator is similar to the download process of Android AOSP Source Library, you can refer to Google's official Android Source Download Document to understand the process.

The difference is that the Android source is downloaded, when initializing the repo client, initializing the download to a branch, specify the Android branch with the following command:

$ repo init-u https://android.googlesource.com/platform/manifest-b ANDROID-4.0.1_R1

when downloading the simulator source code, you need to specify a branch of the emulator. In https://android.googlesource.com/platform/manifest/+refs You can see all the branches you can specify, including the Android branch and the emulator branch, Where the simulator branch mainly has the following:

Emu-1.4-releaseemu-1.5-releaseemu-2.0-releaseemu-2.2-releaseemu-2.3-releaseemu-2.4-arc
Emu-2.4-releaseemu-2.5-releaseemu-master-dev

When initializing, you need to initialize the download of the emulator with the following command, for example, to download the latest release version of version 2.5:

$ repo init-u https://android.googlesource.com/platform/manifest-b emu-2.5-release

back again through repo sync command to download the entire source tree.

The source of the simulator can be understood as a special branch of the Android source code.

Android Emulator compilation

After getting the source code for the Android emulator, go to the following folder:

$ CD External/qemu/android/

Execute the following command to compile the source code:

./rebuild.sh--no-tests

one of the --no-tests tell the compilation system to save time and improve efficiency by not executing the test program after the compilation is complete.

after compilation, the resulting emulator executables and library files are located in the external/qemu/objs/ Directory:

~/emu-2.4-release/external/qemu/android$. /objs/
~/emu-2.4-release/external/qemu/objs$ ls
Android_emu64_unittests emulator64-mips
Android_emu_metrics64_unittests emulator64_simg2img
Bin64 Emulator64_test_crasher
Build Emulator64-x86
Emugl64_common_host_unittests Emulator-check
Emulator Lib
Emulator64-arm lib64
Emulator64_crashreport_unittests lib64glcommon_unittests
Emulator64-crash-service lib64openglrender_unittests
Emulator64_img2simg QEMU
Emulator64_libui_unittests Resources
Emulator64_make_ext4fs

You can then execute the emulator that we compiled, just like the emulator in the SDK:

~/emu-2.4-release/external/qemu/objs$./EMULATOR-AVD Nexus_5_api_21_arm
Android Simulator Debugging

To debug an Android emulator, you need to generate executable files and libraries with information such as debug symbols. This requires a little bit of modification to the compiler script we executed earlier rebuild.sh , in which the program is called android/configure.sh to configure the multi-compilation process:

Run android/configure.sh--out-dir= $OUT _dir "[email protected]" | |
Panic "Configuration error, please run./android/configure.sh."

By default, this configuration program generates a configuration file that instructs the compilation process to generate executables and libraries that do not contain debug symbol information. However, you can android/configure.sh add executable files and libraries with debug symbol information for the execution of your program --symbols .

rebuild.shAfter the change, it's probably like this:

Run android/configure.sh--symbols--out-dir= $OUT _dir "[email protected]" | |
Panic "Configuration error, please run./android/configure.sh."

after modification, re-enter external/qemu/android/ directory and execute the rebuild.sh .

this time, the executable and library files with debug symbol information are generated, which are located in external/qemu/objs/build/debug_info the Directory:

 ~/emu-2.4-release/external/qemu/objs/build/debug_info$ ls 
android_emu64_ Unittests           emulator64_img2simg         Emulator-check
Android_em U_metrics64_unittests   emulator64_libui_unittests  lib64
emugl64_common_host_unittests     Emulator64_make_ext4fs      lib64glcommon_unittests
Emulator                          emulator64-mips             Lib64open Glrender_unittests
Emulator64-arm                    emulator64_ Simg2img         QEMU
emulator64_crashreport_unittests  emulator64_test_crasher
Emulator64-crash-service          emulator64-x86

files with no debug symbol information are still located in external/qemu/objs/ directory.

GDB can then be used to debug executable files and libraries with symbolic information. Enter the external/qemu/objs/build/debug_info directory and execute the following command:

 ~/emu-2.4-release/external/qemu/objs/build/debug_info$ gdb./emulator 
GNU GDB (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1Copyright (C) Free Software Foundation, Inc.
License gplv3+: GNU GPL versi On 3 or later This is the free software:you be free to change and redistribute I T.
There is NO WARRANTY, to the extent permitted by law.  type "Show copying" and "show WARRANTY" for details.
This GDB is configured as "X86_64-linux-gnu".
Type "Show Configuration" for configuration details. For the bug reporting instructions, please see:
Find the GDB manual and other documentation resources online at:
Type "Apropos word" to search for commands related to "word" ...
Reading symbols from Emulator...done.

This command is used to load the executable file. Then, in the debug session of GDB, set command-line arguments for the executable and set the endpoint:

(GDB) Set ARGS-AVD nexus_5_api_21_arm (GDB) Break thread_pthread.cpp:66 (GDB) Break Emug::renderthread::main

It is important to note that when you set an endpoint for a class function, you need to bring its namespace.

Then start the executable program:

(GDB) Run

The program is then broken down when the program executes to the point where we add the endpoint.

Done.



This article is from the NetEase practitioners community, published by the author Han Pengfei authorized.

Learn about NetEase Cloud:

NetEase Cloud Official website: https://www.163yun.com

Yun Chong Conference 0 buy Early Bird tickets: https://yc.163yun.com

Cloud Products Total promotion 50 percent up:https://www.163yun.com/activity/promotion


Android simulator download, compile and debug

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.