How to build and debug android source code

System: ubuntu 14.04


1. download source code and build 


This step is not hard. basically following the doc here:


https://source.android.com/source/building-running.html

You should be able to run emulator after build. 

One tips for re-running emulator after closing the terminal window is to create script like below

method 1:
build/envsetup.sh && lunch full-eng && emulator

method 2:
where to find the emulator?


2. debug android framework java source code

download the ADT eclipse ADT:  http://developer.android.com/sdk/installing/index.html

   it has the eclipse IDE and DDMS debugger


you can create a java project to import all the java source code into eclipse as described in https://source.android.com/source/using-eclipse.html

I have tried the red part below:

          

  1. f Eclipse asks you for a workspace location,  don't choose default, create the workspace at the android root. 

  2. If you have a "Welcome" screen, close it to reveal the Java perspective.

  3. File > New > Java Project

  4. Pick a project name, "android" or anything you like.

  5. Select "Create project from existing source", enter the path to your Android root directory, and click Finish.

  6. Wait while it sets up the project. (You'll see a subtle progress meter in the lower right corner.)

then, pick an app like setting app to debug.  Set break point to the setting app's source code. 


3. common command

- croot:   Changes directory to the top of the tree.
- m:       Makesfrom the top of the tree.
- mm:      Builds all of the modules in the currentdirectory.
- mmm:     Builds all of the modules in the supplieddirectories.
- cgrep:   Greps on all local C/C++ files.
- hgrep:   Greps on all local C/C++ header files.
- jgrep:   Greps on all local Java files.
- mkgrep:  Greps on all local make files.
- rcgrep:  Greps on all local .rc files.
- resgrep: Greps on all local res/*.xml files.
- shgrep:  Greps on all local .sh files.
- godir:   Go to the directory containing a file.




good post:

http://apienthusiast.blogspot.com/2014/06/using-eclipse-to-browse-and-edit-aosp.html


andriod build system

http://elinux.org/Android_Build_System


use emulator

http://stackoverflow.com/questions/9022750/running-emulator-after-building-android-from-source


gdb & gdb server

http://www.thegeekstuff.com/2014/04/gdbserver-example/

http://thinksrc.com/2012/07/15/android-gdb-full-symbol/


http://www.kandroid.org/online-pdk/guide/debugging_gdb.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值