cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Issues Debugging SAP MDK on Windows with Android Emulator

jfreitas91
Explorer
0 Kudos
947

Hello everyone,

I'm facing a persistent issue while trying to debug my SAP MDK application locally on Windows using an Android emulator. The debug session starts correctly and hits breakpoints, but it terminates immediately whenever I type anything in the Debug Console within VS Code. I’d really appreciate help in understanding and resolving this behavior.

In addition to that, when I try to run the "MDK Attach on Android" debug configuration in VS Code, the application is not automatically (re)installed on the emulator with the updated bundle. I need to run the application in "MDK Launch on Android" mode to install the app, which breaks the expected debug flow. I've tried use the both modes to debug.

Debugger Steps

  1. Open the MDK project in Visual Studio Code.

  2. Run the Build Task (Ctrl+Shift+B) to generate the latest metadata.
  3. Start the application using the debug configuration (e.g., “MDK: Debug on Android”).
  4. Set a breakpoint inside a .js rule or action file.
  5. Once the app launches in the Android emulator, the debugger correctly pauses at the breakpoint.
  6. However, as soon as I type any command or expression in the Debug Console, the entire debug session terminates unexpectedly.

This makes it impossible to inspect variables or evaluate expressions dynamically during debugging.

Development Environment

  • Operation System: Windows 11 Pro Edition x64
  • Version: 24H2
  • SO Compilation: 26100.4770
  • Android SDK 35
  • Android SDK Build-tools 35.0.1
  • Java development Kit 17.0.14
  • Node 20.19.0
  • Native Script 8.9.2
  • Android Studio + SDK installed and configured
  • VS Code + MDK Extension  installed and configured

Steps Taken

  1. Installed the MDK SDK locally and executed create-client.cmd to generate the project.
  2. Verified environment variables:
    - ANDROID_HOME
    - JAVA_HOME
  3. Ran `tns doctor` successfully (no errors).
  4. Started the project using the SAP MDK VS Code extension
  5. The app launches on the emulator and hits the debugger line inside a .js script.
 

What I've Already Tried

  • Updated and adjusted launch.json with different "trace", "sourceMaps", and "watch" settings.

  • Reinstalled NativeScript CLI and Android SDKs.
  • Tried running VS Code in both Admin and normal modes.
  • Updated all VS Code extensions.
  • Tested with different emulators (x86, x86_64).

 

View Entire Topic
bill_froelich
Product and Topic Expert
Product and Topic Expert

I always use Attach on Android for my debugging but when doing this I also have a terminal window open where I have executed ns run android --emulator --no-hmr and the command is still running providing console output to the terminal.  In this scenario when I run the Build Task from within VS Code it copies the updated bundle to the client and because the ns run is still active in the terminal window it relaunches the client.  The downside is that the relaunch will disconnect the debugger.  As a result I typically use App Update an deploy from VSCode to App Update and Check for Updates in my client to pickup the changes.  This does not disconnect the existing debugger.

Regarding the typing in the debug console terminating the session this is something we are aware of and working to find a solution.   The Debug Console does support dynamic input during paused breakpoints in MDK/NativeScript apps.  This is currently only affecting Android (on both Windows and Mac) in the more recent versions..  The workaround is to paste the statement you want to execute into the debug console.  Then it works as expected.  So I am currently opening a new tab as a scratch pad to type out commands to copy and paste into the debug console if it isn't something I can copy and paste directly from the source code view.

Hope this helps.

Bill

 

jfreitas91
Explorer
0 Kudos

Thanks so much for your help, Bill! This approach worked for what I needed.
Just to share with everyone: first, I ran the build task, and then I launched the MDK app using the "MDK Launch on Android" mode. This way, I didn't lose the auto-refresh functionality, and the build task ran automatically.
To view a variable's value at runtime, I simply copied the variable I needed and pasted it into the Debug Console.

debbug MDK app.png