Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug android framework services?

Is it possible to debug the android framework's system services?

I have come across these links, but wasn't successful enough to debug the system services.

http://android.opensourceror.org/2010/01/18/android-source/

like image 796
prijupaul Avatar asked Feb 10 '12 10:02

prijupaul


3 Answers

I found and tested some working instructions for Android Studio here:

I choose API 17 because it doesn't have emulator rotate bug.

important steps:
0) make sure your android studio has downloaded sdk 17 with sources.
1) create any simple android project. make target sdk 17. min sdk 17 and compile with 17. build tools version doesn't matter. (File-> Project Structure-> app under Modules -> Flavor)
2) create emulator instance with api 17
3) open ddms, highlight system_process, that is it. (Tools -> Android - > Android Device Monitor)
4) for the simple project, config debug profiles: remote 8700, Run->Edit Configurations -> + -> Remote -> port 8700
5) from the simple project. launch debug with the profile. (now you will notice ddms's system_process has an special bug icon)
6) open file $(Android_Studio)/sdk/sources/android-17/com/android/server/am/ActivityStack.java in android studio, and then set a breakpoint at: realStartActivityLocked(…) func
7) IMPORTANT STEP: in android studio, from bottom pane, select Debugger -> Threads, WAIT threads are populated. because it means studio is connected with ddms now.
8) from emulator, launch any app/ or your simple app.
9) breakpoint will be intercepted, if not try restart the app in emulator again.

two refs:
http://apienthusiast.blogspot.com/2014/06/debugging-android-java-framework.html
http://source.android.com/source/using-eclipse.html
http://jmlinnik.blogspot.kr/2011/12/debug-built-in-applications-in-eclipse.html
https://software.intel.com/en-us/articles/android-system-level-javac-code-debugging

http://apienthusiast.blogspot.ca/2014/07/debugging-android-native-applications.html
like image 102
Sam Avatar answered Sep 27 '22 19:09

Sam


You need an eclipse project to be able to debug Android framework services. The process of creating an eclipse project for AOSP is not that straight forward. The instructions at Android source site leaves lot of details. You will either end up with broken project or broken AOSP builds. If you break AOSP builds, you probably have to go to each folder where eclipse project created any artifacts and manually delete them.

The article Debugging Android Java framework services provides step by step tutorial from creating a project to using that project for debugging Android java framework services. Please check that link.

like image 22
videoguy Avatar answered Sep 27 '22 19:09

videoguy


Is it possible to debug the android frameworks system services?

If you are compiling and building your own firmware, yes. See the "Debugging the Emulator" section on the Using Eclipse page in the AOSP docs.

like image 21
CommonsWare Avatar answered Sep 27 '22 18:09

CommonsWare