Debug with Android Emulator
摘要
研究Android, 最好的方法莫過於Step by Step地Debug。本文記錄了下載編譯x86 emulator及Debug Java Frame和C++庫的過程。以WebKit為例,介紹Android的除錯過程。
程式碼下載
從Google下載原始碼,本文以Android 4.2.2 r1學習WebKit為例。如果你也和我一樣從Google下載Android原始碼有困難,可以從這裡下載
下載eclipse:
>>>>
下載ADT, 需要和Android SDK對應,檢視一下Android 4.2.2 r1的SDK需要的ADT版本是20.0.0
$ cat sdk/files/plugin.prop
# begin plugin.prop
plugin.version=20.0.0
http://dl.google.com/android/ADT-21.0.0.zip編譯之前
先解決兩個編譯bug: http://blog.csdn.net/telnetchen/article/details/17596181
加上除錯所需要的編譯選項
在這裡加上framework的除錯資訊
frameworks/base/core/java/android/webkit/DebugFlags.java
拷貝build/buildspec.mk.default到根目錄並且改名為buildspec.mk,加入以下內容:
DEBUG_MODULE_libwebcore:=true
DEBUG_MODULE_libxml2:=true
DEBUG_MODULE_libchromium_net := true
TARGET_CUSTOM_DEBUG_CFLAGS:=-O0 ADDITIONAL_BUILD_PROPERTIES += debug.db.uid=100000
查詢所有模組:
確認以下的配置(false),以免出現檔案過大的編譯錯誤
external/webkit、Android.mk:
LOCAL_PRELINK_MODULE := false
編譯
source build/envsetup.sh
lunch full_x86-eng
make sdk -jx
生成的SDK目錄:out/host/linux-x86/sdk/android-sdk_eng.${USER}_linux-x86
安裝ADT及指定SDK
開啟Eclipse, Help -> Install New Software ...
安裝完ADT後,Eclipse要求重啟,啟動起來會要求SDK
建立一個簡單的WebKit應用並開始除錯
Java部分可以在Eclipse中逐步跟蹤,對於C++部分,還需要用gdb
Run the following command on your computer: adb forward tcp:5039 tcp:5039 Run the following command on your running emulator: gdbserver 10.0.2.2:5039 attach pid Run the following commands in gdb: set solib-absolutep-refix out/target/product/generic_x86/symbols set solib-search-path out/target/product/generic_x86/symbols/system/lib file out/target/product/generic_x86/symbols/system/app_process在某個地方設定一個break point,就可以用你喜歡的gdb了.
對於Java部分如果還提示找不到某個檔案,可以讓它去framework目錄下繼續找。
相關文章
- android: ADB錯誤“more than one device and emulator”Androiddev
- Android Studio在android Emulator中執行的專案黑屏Android
- Opera Mobile Emulator for desktop
- android I/DEBUG堆疊資訊Android
- emulator: ERROR: unknown virtual device nameErrordev
- 解決Android 虛擬機器執行The emulator process for AVD was killed.錯誤。Android虛擬機
- Android使用Custom debug keystoreAndroid
- Failed to install *.apk on device 'emulator-5554!AIAPKdev
- Android BuildConfig.DEBUG的妙用AndroidUI
- Android應用程式的debug屬性Android
- Android資料庫檢視庫---Android-Debug-DatabaseAndroid資料庫Database
- Android除錯資料庫的福音:Android-Debug-DatabaseAndroid除錯資料庫Database
- Android開發者指南(1) —— Android Debug Bridge(adb)(上) 薦Android
- Android Studio debug斷點 介面卡頓Android斷點
- OpenMLDB SQL 開發除錯神器 - OpenMLDB SQL EmulatorSQL除錯
- SDL_app:emulator.exe應用程式錯誤APP
- 判斷Android 當前版本是否為debug版本Android
- Debug BAPIAPI
- debug exceptionException
- Andorid“emulator: ERROR: unknown virtual device name”問題解決Errordev
- Android 你不知道的除錯技巧(Debug操作彙總)Android除錯
- Android解決The APK file app-debug.apk does not exist on disk.AndroidAPKAPP
- Android Studio 掌握這些除錯技巧,Debug 能力不能再高啦Android除錯
- Debug-Records
- Debug模式應用程式輸出Debug除錯資訊模式除錯
- 暴力破解Paragon CD Emulator時間及功能限制 (7千字)Go
- AS之Debug除錯除錯
- Clang Plugin 之 DebugPlugin
- Code::Blocks Debug配置BloC
- How to debug Typescript in browserTypeScript
- rman target / debug trace
- debug 和 release 應用
- Node程式debug小記
- Error: Debug Failure at typeToStringErrorAI
- IDEA中使用DebugIdea
- redis debug命令詳解Redis
- Debug追蹤eclipseEclipse
- Bash指令碼debug攻略指令碼