3

I've been working with AS 1.4 for quite a while and new native debugging feature is especially useful.

However native debugging does not work on my Samsung Galaxy Note 10.1 2014 (Android 4.4). When I try to start the native debugging session I see the following message:

Starting LLDB server: run-as com.example.hellojni /data/data/com.example.hellojni/lldb/bin/start_lldb_server.sh /data/data/com.example.hellojni/lldb /data/data/com.example.hellojni/lldb/tmp/platform.port1445003703353 "lldb process:gdb-remote packets"

Error while launching debug server on device: com.android.tools.ndk.run.DebuggerContext$StartServerException: java.lang.IllegalStateException:
Failed to read platform port /data/data/com.example.hellojni/lldb/tmp/platform.port1445003703353

I also found an open issue: https://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&groupby=&sort=&id=185061

Is there a way to solve this?

Aleksei Petrenko
  • 6,698
  • 10
  • 53
  • 87

2 Answers2

3

See https://code.google.com/p/android/issues/detail?id=187003

You need root access on your device, but then chmod 4750 /system/bin/run-as may solve the problem.

If you don't have root access, you can modify your app, and start LLDB server with your package's identity, using Runtime.exec().

Alex Cohn
  • 56,089
  • 9
  • 113
  • 307
  • I tried that and it didn't help. I managed to change the permissions for run-as: `-rwsr-x--- root shell 9500 2015-03-25 21:42 run-as`, but I get completely the same error message now. – Aleksei Petrenko Nov 03 '15 at 16:42
  • I should probably try the second method you suggested. Do you know where I can find more details about `Runtime.exec()` approach? – Aleksei Petrenko Nov 03 '15 at 17:16
  • 1
    This article is very good and describes the process in depth: http://ian-ni-lewis.blogspot.co.il/2011/05/ndk-debugging-without-root-access.htm. It is a bit old and speaks about gdb, but it is still very relevant today. – Alex Cohn Nov 04 '15 at 07:09
  • 1
    Did you try `setxattr /system/bin/run-as security.capability`? – Alex Cohn Nov 04 '15 at 07:16
1

I encounter Android Studio 3.5 similar issue with LLDB debugger - where "Starting LLDB server" process hangs forever, no debugging process is started and after solving this I encounter another issue. The issues with workarounds are explained in bug reports I submitted:

  1. Android Studio C++ Debugger startup silently ignores phone LLDB setup critical issues - workaround: ensure to use AVD emulator based on Google API and not Google Play (no root access)
  2. Android Studio C++ Debugger uses wrong paths on phone in LLDB setup procedure causing: failed to get reply to handshake packet - workaround: check which paths are wrong and create them on device like: mkdir -p .../bin
Robert Lujo
  • 15,383
  • 5
  • 56
  • 73