How to attach debugger for Deep Link Android App trigger debug launch?
Asked Answered
O

2

17

As per posted in https://developer.android.com/training/app-indexing/deep-linking.html, we could start the deeplink App Launch using the below command

adb shell am start -W -a android.intent.action.VIEW -d "example://gizmos" com.example.android

But if I want to start debugging, I could add a -D, as below

adb shell am start -W -a android.intent.action.VIEW -d "example://gizmos" com.example.android -D

My App got launched, but it is there stating

Waiting For Debugger
Application Android System (process system:ui) is waiting for the debugger to attach

From there, I check my Android Studio, it is not attached. Wonder how could I get it attached?

Ordinate answered 18/2, 2017 at 3:2 Comment(0)
M
5

You'd either have to manually attach it after launching, or already have the app running and attached then launch your deeplink. There's no way for the phone to know it needs to attach to a debugger on a connected PC when it launches an app.

Magnesia answered 18/2, 2017 at 3:5 Comment(2)
How to 'manually attach'? Is it from the Android Studio, or command line we could do so?Ordinate
Generally Android studio if you plan on using it as a graphical debugger. Under the build menu there's an option "Attach debugger to Android process"Magnesia
A
44

there is a great article and a great comment under it.

Briefly:
1. Before the line you want to debug put Debug.waitForDebugger().
2. Put breakpoint where you need it.
3. Run application (from deeplink, in this case).
4. You will see it's frozen.
5. In Android Studio attach debugger to process.
6. Voila! Now you have debugger activated on that breakpoint.

In this way I was able to debug deeplinks.

Argillaceous answered 6/7, 2018 at 15:9 Comment(1)
Great. Works directly in Android Studio (4.0.1), no need for command-line toolsIncompatible
M
5

You'd either have to manually attach it after launching, or already have the app running and attached then launch your deeplink. There's no way for the phone to know it needs to attach to a debugger on a connected PC when it launches an app.

Magnesia answered 18/2, 2017 at 3:5 Comment(2)
How to 'manually attach'? Is it from the Android Studio, or command line we could do so?Ordinate
Generally Android studio if you plan on using it as a graphical debugger. Under the build menu there's an option "Attach debugger to Android process"Magnesia

© 2022 - 2024 — McMap. All rights reserved.