【问题标题】:How to debug android framework services?如何调试android框架服务?
【发布时间】:2012-03-02 20:15:08
【问题描述】:

可以调试android框架的系统服务吗?

我遇到了这些链接,但未能成功调试系统服务。

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

【问题讨论】:

标签: android debugging service frameworks android-source


【解决方案1】:

我找到并测试了 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

【讨论】:

    【解决方案2】:

    您需要一个能够调试 Android 框架服务的 eclipse 项目。为 AOSP 创建 Eclipse 项目的过程并不那么简单。 Android源站点上的说明留下了很多细节。您最终会得到损坏的项目或损坏的 AOSP 构建。如果您破坏了 AOSP 构建,您可能必须转到 eclipse 项目创建任何工件的每个文件夹并手动删除它们。

    文章Debugging Android Java framework services 提供了从创建项目到使用该项目调试Android java 框架服务的分步教程。请检查该链接。

    【讨论】:

      【解决方案3】:

      可以调试android frameworks系统服务吗?

      如果您正在编译和构建自己的固件,可以。请参阅the Using Eclipse page in the AOSP docs 上的“调试模拟器”部分。

      【讨论】:

      • 感谢您的回复。我正在做设备上调试。我想调试\packages\apps\Launcher2\ 中的launcher2 应用程序,这利用了frameworks\base\services\java\com\android\server 中的系统服务WallpaperManagerService。所以现在,我无法将此文件夹导入 Eclipse 并调试 WallpaperManagerService 中的代码。你有什么方法可以将代码导入到 Eclipse 并从那里调试吗?谢谢,普里尤
      猜你喜欢
      • 2018-11-19
      • 2021-11-18
      • 1970-01-01
      • 2013-08-03
      • 2013-07-07
      • 1970-01-01
      • 1970-01-01
      • 2017-03-10
      • 2023-03-17
      相关资源
      最近更新 更多