13

Recently upgraded to Android Studio 4.2.1

I can launch my app successfully but when I try to attach the debugger I get the error in the question title (see screenshot below).

The app just gets stuck on the "Waiting For Debugger" screen.

Everything worked as expected prior to upgrade.

This is the output from the debug log

$ adb shell am start -n "com.*.*/com.*.*.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -D
Waiting for application to come online: com.*.* | com.*.*.test
Waiting for application to come online: com.*.* | com.*.*.test
Connected to process 9869 on device 'amazon-kfmuwi-G0W0X8089256FRU1'.
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
W/ActivityThread: Application com.*.* is waiting for the debugger on port 8100...
I/System.out: Sending WAIT chunk
Connecting to com.*.*
Now Launching Native Debug Session
com.intellij.execution.ExecutionFinishedException: Execution finished

Process finished with exit code 0

In logcat I also see

2021-05-19 12:55:32.855 10394-10394/? E/azon.kindle.cm: Not starting debugger since process cannot load the jdwp agent.

I have tried: Restarting Android device Restarting development device Invalidating and Restarting Android Studio Reinstalling Android Studio

My system is running Pop!_OS 20.10

Debug error

Andrew McFaul
  • 203
  • 2
  • 9

5 Answers5

34

I've solved that by installing 'libncurses5' and 'ia32-libs' packages

This is a known issue and is provided on the android developer's official page. Here is the link https://developer.android.com/studio/known-issues?hl=de#native_debugger_crashes_with_debugger_process_finished_with_exit_code_127

It turns out it's a Linux-specific issue and is because Linux uses upgraded 'libncurses6' and android studio uses 'libncurses5' required to run the debugger.

Simran Sharma
  • 852
  • 7
  • 16
Max Elkin
  • 924
  • 8
  • 8
  • 20
    Great, this solved it for me as well: `sudo apt install libncurses5` – ffurrer May 31 '21 at 14:43
  • 5
    Yep. installing `libncurses5` fixes it for me too – Michael Sotnikov May 31 '21 at 19:38
  • 2
    In this case, for Arch linux is the package `ncurses5-compat-libs` – João Eudes Lima Jun 16 '21 at 22:26
  • Why does this work? Please add context so people don't just sudo install things that may be unrelated to their issue. – topher217 Jul 06 '21 at 03:52
  • As per the Android Known Issues documentation: "This error occurs on Linux-based platforms when starting the native debugger. It indicates that one of the libraries required by the native debugger is not installed on the local system. The name of the missing library may be already printed in the idea.log file. .... Typically, the missing library is ncurses5 as some recent Linux distributions have already upgraded to ncurses6." - [link here](https://developer.android.com/studio/known-issues?hl=de#native_debugger_crashes_with_debugger_process_finished_with_exit_code_127) – Diego S. Seabra Jul 13 '21 at 17:41
  • @topher217 check the reason here: https://developer.android.com/studio/known-issues?hl=de#native_debugger_crashes_with_debugger_process_finished_with_exit_code_127 – Simran Sharma Aug 21 '21 at 00:23
  • @SimranSharma I see reference to 'ncurses5' which would weakly tie this to the answer (although it should also include a reference to what is assumed in that 'libncurses5' is a apt package containing the said 'ncurses5' lib) , but no mention of 'ia32-libs'. So why install it? These kinds of no-context sudo answers are dangerous imo. – topher217 Aug 23 '21 at 01:42
  • @topher217 I completely agree with you. I did not install it directly due to the same reason. I read about it first on official documentation and then did the necessary thing – Simran Sharma Aug 23 '21 at 10:26
  • i'm getting errors: E: Failed to fetch http://my.archive.ubuntu.com/ubuntu/pool/universe/n/ncurses/libtinfo5_6.2-0ubuntu2_amd64.deb 404 Not Found [IP: 202.79.184.254 80] E: Failed to fetch http://my.archive.ubuntu.com/ubuntu/pool/universe/n/ncurses/libncurses5_6.2-0ubuntu2_amd64.deb 404 Not Found [IP: 202.79.184.254 80] E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing? on my Ubuntu 20. any idea? – programmer dreamer Oct 25 '21 at 08:13
6

I've solved this by installing 'libncurses5' only

sudo apt install libncurses5

Thanks to Max Elkin

Asfand
  • 71
  • 4
0

I eventually solved this by rolling back to Android Studio 4.1.

Andrew McFaul
  • 203
  • 2
  • 9
  • yes, same here, but the same thing is happening with Artcic Fox, so that is a short term answer – alexm May 19 '21 at 22:11
  • are you using Ubuntu? in Windows and MAC works fine, it seems the problem is the adb being killed by a another process, I cannot get rid off, until I close Android Studio and do an adb reconnect. but basically this bugs the entire connection of adb with a device while Android Studio is running. – alexm May 19 '21 at 22:15
  • @alexm Yes, I am using Pop! OS which is built on Ubuntu. I suspected something similar but I did a simple `ps aux | grep adb` command and couldn't see any evidence that adb was being killed. – Andrew McFaul May 20 '21 at 14:05
  • I'd like to confirm that I get this issue on ubuntu – Michael Sotnikov May 23 '21 at 14:31
0

I rolled back AS from 4.2 to 4.1.3 which solved the error

0

In case the accepted answer doesn't help, here's how to find the root cause:

  • Search for the Debug log settings action (via CTRL + SHIFT + A)
  • Set #com.jetbrains.cidr.execution.debugger:trace in the dialog (source)
  • Try run or attach the debbuger
  • Search for the Collect Logs and Diagnostic Data action (via CTRL + SHIFT + A)
  • Inspect the idea.log file inside the zip. It should show why the debugger fails.

For example, I saw this error brains.cidr.execution.debugger - LLDBFrontend: Fatal Python error: config_get_locale_encoding: failed to get the locale encoding: nl_langinfo(CODESET) failed

Which was fixed by setting this in ~/.zshrc (source)

export LC_ALL="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
Asapha
  • 643
  • 8
  • 14