如何为Deep Link Android App附加调试器触发调试启动?

Ely*_*lye 7 debugging android android-studio android-deep-link

根据https://developer.android.com/training/app-indexing/deep-linking.html中的帖子,我们可以使用以下命令启动深层链接App Launch

adb shell am start -W -a android.intent.action.VIEW -d "example://gizmos" com.example.android
Run Code Online (Sandbox Code Playgroud)

但是如果我想开始调试,我可以添加一个-D,如下所示

adb shell am start -W -a android.intent.action.VIEW -d "example://gizmos" com.example.android -D
Run Code Online (Sandbox Code Playgroud)

我的应用程序已经启动,但它已经存在

Waiting For Debugger
Application Android System (process system:ui) is waiting for the debugger to attach
Run Code Online (Sandbox Code Playgroud)

从那里,我检查我的Android Studio,它没有附加.不知道我怎么能附上它?

Gol*_*ene 15

在它下面有一篇很棒的文章和一篇很棒的评论.

简要说明:
1.在你要调试的行之前Debug.waitForDebugger().
2.将断点放在需要的地方.
3.运行应用程序(在这种情况下,来自deeplink).
你会看到它被冻结了.
5.在Android Studio中附加调试程序进行处理.
瞧!现在,您已在该断点上激活调试器.

通过这种方式,我能够调试深层链接.


Gab*_*han 5

您要么必须在启动后手动附加它,要么已经运行应用程序并附加,然后启动深度链接。当手机启动应用程序时,手机无法知道它需要连接到连接的 PC 上的调试器。