cancel
Showing results for 
Search instead for 
Did you mean: 

Issues Debugging SAP MDK on Windows with Android Emulator

08-04-2025 4:08 AM
jfreitas91 Explorer
2775 views 6 comments Go to solution
0 Likes
SAP Managed Tags
Labels
mdkSAP BTPSAP Mobile Development Kit
Subscribe

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).

 

0 Likes

Accepted Solutions (1)

Accepted Solutions (1)

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 Likes

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

0 Likes
Hi Bill , I was to debug code locally but with new version of SAP Mobile Development Kit Editor, it is not working. Tried above steps but still it is not working. All breakpoints are getting displayed in disabled state. Please help.
bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Likes
@girish_kumar1-merkle I suggest starting a new thread for your issue as it appears to be a different issue. Please be sure to confirm the version of the MDK plugin you are using along with platforms, os etc.

Answers (1)

Answers (1)

Chris1973
Active Contributor

Hi @jfreitas91 

Thank you for the details provided.

Following our investigation into the debugging issues with SAP MDK on Windows and Android emulators, here is a quick summary:

Debug Console Crash

This is a known limitation. The Debug Console doesn’t support dynamic input during paused breakpoints in MDK/NativeScript apps. Debugging should be done using breakpoints, variable inspection, and console.log outputs.

Attach Mode Not Reinstalling App

This is by design. The Attach mode is only for connecting to a running app and won’t trigger a reinstall. You should use MDK Launch on Android to deploy updates.

Here are our recommendations:

Ensure you

Ensure you use MDK Launch on Android for deployment and debugging combined.

Ensure to avoid entering commands into the Debug Console. Instead use logging and variable inspection tools instead.

Then, consider raising an SAP support ticket if dynamic evaluation in the Debug Console is critical to your workflow. As of now, it’s not officially supported.

I hope this gives clarity. I am happy to help if you have further questions.

If you find my response helpful, kindly accept the answer and award a Kudos to this post. Your support is appreciated.

Best regards

Chris

jfreitas91
Explorer
0 Likes
Do you know if this issue occurs only on Windows or also on macOS?