Android Studio Debugger process finished with exit code 127 - android

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

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.

I've solved this by installing 'libncurses5' only
sudo apt install libncurses5
Thanks to Max Elkin

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

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

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"

Related

Android Instant Apps: How to debug an instant app?

When I debug my instant app on Android Studio, the debugger attaches to instant app process and pauses execution at most breakpoints. However it seems to ignore breakpoints at my main activity's onCreate method. I've tried "Debug" and "Attach Debugger to Android Process" options. What am I missing?
Basic information about how to use Android Studio debugger to debug an Android app is available at Developer Documentation Debug Your App
.
Android Studio debugger works normally most of the time when debugging an instant app. However, you will notice that the debugger will fail to stop at breakpoints early in the app's lifecycle (such as Application.onCreate or Activity.onCreate) on devices running Android N and below.
When your instant app is up and running, it runs under your app's package name. However, there is a short period of time during app startup when it runs under a temporary package name, in the following form:
com.google.android.instantapps.supervisor.isolated[0-9]+
This temporary name is assigned by the runtime. Because Android Studio is not aware of this name, the debugger will not attach to this process.
The workaround is to find out this temporary name and use adb to set the app to debug. This can be done by running the following command in terminal before running your app. It will print out the name when your app starts.
=> adb shell 'while true; do ps | grep com.google.android.instantapps.supervisor.isolated; sleep 1; done'
u0_i6 31908 630 1121664 29888 0 00ea57eed4 R com.google.android.instantapps.supervisor.isolated15
Once you identify the package name, use the following command which will pause and make your instant app process to wait for the debugger. Then attach the debugger normally, but choosing the temporary process name in the Choose Process window by clicking on “Show all processes”.
=> adb shell am set-debug-app -w --persistent com.google.android.instantapps.supervisor.isolated15
I had also problems recently debugging instant apps.
with multiple log messages
"Waiting for application to start debug server"
in the debug window and after several retrials
"Could not connect to remote process. Aborting debug session."
The way I solved the issue is
by using the "Attach To Process" option from Android studio "Run" menu.

Unable to attach debugger in Android Studio - localhost:8600 java.net.ConnectException

I cannot attach the debugger in Android Studio while running debug on a phone.
I’m currently using a Samsung S4, running Android 4.4.4 (but have tried an S5, S6, S7, and Moto E phone on various Android versions). It times out when I try to run it with either of the following errors:
I/System.out: Sending WAIT chunk
W/ActivityThread: Application is waiting for the debugger on port 8100...
Or
failed to open debugger port localhost:8600 java.net.ConnectException "connection refused"
and the App says:
Waiting For Debugger
Application (process ) is waiting for the debugger to attach.
Force Close
Android Studio version:
Android Studio 2.2.2
Build #AI-145.3360264, built on October 18, 2016
JRE: 1.8.0_112-release-b05 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac version:
10.11.6 (15G1004)
I can successfully connect and run the application, I just can’t get the debugger to attach when I do Run > Debug App > select the connected phone > OK.
I have been able to run the app in debug on other computers (both Windows and Mac) with the same phones.
Various approaches I have tried from hours of debugging and online searching:
Invalidate Caches/Restart Android studio
Check for anything else running on ports 8100, 8600, 8601, etc., nothing comes back when I run the following from bash:
$ # while Android studio is trying to attach the debugger
$ lsof -i :8100
$ lsof -i :8600
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
studio 6282 peter 125u IPv4 0x973c7e31bda641ab 0t0 TCP 192.168.1.16:64022->ip-166-62-27-181.ip.secureserver.net:asterix (SYN_SENT)
$ lsof -i :8601
$
$ # after Android studio fails to attach the debugger
$ lsof -i :8100
$ lsof -i :8600
$ lsof -i :8601
$
Run Tools > Android > Android Device Monitor - it shows my device, but I can’t run Android Device Monitor while I’m trying to debug the app, it says, “Monitor will be closed to enable ADB integration. Continue?” I haven’t found anything useful here.
Searching for and killing adb processes
ps aux | egrep '(adb|java)'
... then doing `kill <pid>` or `kill -9 <pid>` if necessary for the found ones
Restart Android studio
Restart my computer
Update Java JDK from the Oracle website—however, I’m not sure why Android Studio still says, “JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o”
Completely uninstall and reinstall android studio - e.g., https://stackoverflow.com/a/18458893/376489 - weirdly, I think this worked for one run of the debugger and then not again…
Tried Run > Attach debugger to Android Process - this didn’t help
Tried running:
~/Library/Android/sdk/platform-tools/adb kill-server &&
~/Library/Android/sdk/platform-tools/adb start-server
Tried unchecking Run > Edit Configurations > Run/Debug Configurations > Skip installation if APK has not changed
Check System Preferences > Security & Privacy > Firewall - this is turned off
Update 1: tried revoking permissions on the phone as well as restarting it
Update 1: muted all breakpoints Android Studio
Are there any other ideas for what might be going wrong or anything meaningful in the details I added above?
Quite embarrassing, but it looks like some time ago I had entered an ip address into my /etc/hosts file to test something as localhost and never removed it. I found a comment on another post saying to check that the following is in your /etc/hosts:
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
Upon commenting out that spurious line, the debugger is now working. Given I have a dozen or so other IPs in that file (so I can more easily test remote hosts with a friendly name), I must have not noticed this one at the bottom. I think a more foolproof approach to verifying if this is the problem or not is to ping localhost and verify that it resolves to the ip address of 127.0.0.1, e.g.,
$ ping localhost
PING localhost (127.0.0.1): 56 data bytes
Great comments and suggestions from other folks here too, thanks!
I just experienced the same issue. It seems, as if Android Studio Version 2.2 has some issues with a non-attaching debugger as you can see for example here and here.
In my case the following helped:
Remove the launch profile for your app by going to Run -> Edit Configurations... and removing the profile there. Don't forget to hit the OK button after you have removed the profile. :)
Create a new launch profile from scratch by again going to Run -> Edit Configurations..., hitting the + button, selecting an Android App launch profile and selecting your start module. The other default values of the profile were just fine.
Hope this helps you as well.
I am using a real device. Simply deleting the app on the device, and then running from Android Studio solved this issue.
It seems Android Studio had trouble with overwriting the file that was already on the phone.
1.try cleaning project Build->clean project
2.do file->Invalidate/cache restart
if above not helps you..
3.try to change the data cable you are using to connect your phone.
if nothing above helps, install Android wifi ADB plugin and try to do debug over wifi.
Support for a true debug build. Developers no longer need to add the android:debuggable attribute to the tag in the manifest — the build tools add the attribute automatically. In Eclipse/ADT, all incremental builds are assumed to be debug builds, so the tools insert android:debuggable="true". When exporting a signed release build, the tools do not add the attribute. In Ant, a ant debug command automatically inserts the android:debuggable="true" attribute, while ant release does not. If android:debuggable="true" is manually set, then ant release will actually do a debug build, rather than a release build.
In my case i struggling this issue with 5 hour and found that the
minifyEnabled true is the main culprit so change
minifyEnabled false work for me
My app build.gradle file look like
buildTypes {
debug {
signingConfig signingConfigs.debug
minifyEnabled false
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
I also got same error and this thing worked for me
1. Open Android Studio -> Terminal
2. Change directory to $Android SDK Path$\platform-tools
3. Write command adb get-state and hit enter.
Then you will get this output
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
I have the opposite problem with Android Studio 3.3, trying to debug a wi-fi-connected phone.
After selecting the device in Android Studio, I receive the following message:
Error running 'app': Unable to open debugger port (localhost:8600):
java.net.ConnectException "Connection refused: connect"
I also have IPV-6 enabled on my network.
The issue is that "localhost" resolves to ::1 on my machine by default, but ADB studiously binds explicitly to 127.0.0.1. I happen to know this because I spent the day trying to make ADB connect to emulators running on a remote machine (not since Android 4.4 unfortunately.
To solve the problem, add the following line to \windows\system32\drivers\etc\hosts:
127.0.0.1 localhost
This problem was driving me crazy for about 2 weeks. What finally fixed it for me was changing "auto" to "java" in the debugger process selection window like this:
Try using below commands on terminal-
adb kill-server
adb start-server
It works well.
Simply not using my google pixel 1st gen and using my new Nokia 7 plus fixed this issue :).
There is a known issue with Android Studio 4.2.1 on Ubuntu 20.04 when debugging native code.
There is an easy way to check if you are concerned, just run the following command line that should not finish with an error:
${android-studio-dir}/bin/lldb/bin/LLDBFrontend
At first i tried all the above ways, did not help.
I have two computers with same settings.
But at one worked at other error.
It's given me an idea that it can be "hardware" problem.
I switched USB to other slot with USB3.0 and used short cable and
WOW it began work.
I suggest there some delay in USB2.0 (polling), therefore process begin out of synch.

Not able to debug app on android device - Android Studio 2.0

I am not able to debug an app on my device (Asus Zenphone 2) after I updated android studio to 2.0. I keep seeing below message in debug tab right after I click on debug icon in Android studio.
Message in debug tab in Android Studio UI
---------------------------------------------------------------
Waiting for application to come online: packagename
Waiting for application to come online: packagename
Waiting for application to come online: packagename
Waiting for application to come online: packagename
I keep seeing Alert Dialog with the title "Waiting for Debugger" and Force close button all the time.
I searched but it seems only two results from google for that message.
I restarted Android studio, checked developer settings on phone...
Have anyone faced with this issue. Please help me. I cannot run the emulator, because my mac will be too lag. Thank you in advance.
The problem is that after installing and starting to launch the app, that debugger client that AndroidStudio starts is unable to connect to the debugger server on the device. This can have many causes, see this answer and the other answer shown on this page and see if one solves the problem for you
To help figure out the problem, look at the 'Console' tab of the 'Debugger' window in AS. One of the first few lines should look like this:
$ adb shell am start -n "com.acme.audtest/com.acme.AudTest" -a
android.intent.action.MAIN -c android.intent.category.LAUNCHER -D
Cut and paste that line into a command prompt, REMOVE THE '-D', and execute it.
It your app ('AudTest') comes up without error, the problem is in AS, is communication to the device, or the configuration of the device. If the app doesn't start, it is in the .apk. (Not the complete solution, but starts to point you in the right direction -- for which of the solutions below applies to your situation.)
First I select the second option, and it worked fine. But then don't know why I change to select first option. So, the debugger shows the message Waiting for application to come online forever. And I did not notice that, just thought another app prevent me debug or that was an issue with Android Studio 2.0.
So, just check to second option will solve my issue. Thank all.
Restarting Android Studios (2.1.1) resolved this for me.
There are two possibilities:
1.USB Debugging off :
Start Developer Option of your devices
Switch On USB Debugging
2.In Android-Studio : File -> Invalidate Caches / Restart
anyone can be useful for you.Try it
The correct answer is close your Android Device Manager.
None of these suggestions worked for me till I closed it.
For me the problem was in "Android Studio" + "Intellij IDEA" running side-by-side. Was fixed by disabling bundled "Android plugin" in "Intellij IDEA".
(Note: problem appeared only with some later versions of these IDEs)
Nothing worked for me except one solution...
Clearing the Intellij IDEA (Android Studio) .idea directory which contains configuration information worked for me:
Exit Android Studio
Navigate to the project you are trying to debug
Backup any files inside .idea that you modified (if your project checks any of these into VCS)
Delete .idea directory
Open the project in Android Studio
I had to remove the parameter
android:exported = "false"
from the main activity.
if you get this problem on the emulator, running adb reconnect worked for me. there is a similar command for devices adb reconnect device
**
This answer might help for those Who have successfully connected their
device along netbeans NB Android but on debug there's no application
being appear on device.
**
Ok so solution is check your android device version in mobile setting click on about device at last: you will know your android version there.
Now choose the same version for your netbeans android project.
Right click on project name click on properties and then change target with same as your android device.
(In my case android version was 4.4.2 so I selected the same for my project target)
Before to go ahead click on service tab next to project tab in netbeans then right click on Android device and click on restart ADB.
Finally you need to right click on project again and click on clear and build.
Now you can run with hope to get result.
I just wanted to share my experience as I had the same error and there was no way to solve it using all the solutions you guys posted. I even deleted several times my virtual device, no way to make it work again.
In my App I have a custom permission com.example.CUSTOM_PERMISSION and I wanted to use it to protect my Main Activty from a confused deputy attack.
<permission android:name="com.example.CUSTOM_PERMISSION"
android:label="#string/permlab_deadlyActivity"
android:description="#string/permdesc_deadlyActivity"
android:permissionGroup="android.permission-group.COST_MONEY"
android:protectionLevel="dangerous" />
.
.
.
<activity
android:permission="com.example.CUSTOM_PERMISSION"
android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
Somehow that property android:permission was preventing my app to install and run on the virtual device, even though it could be compiled and build with Gradle successfully.
Just after removing it, everything is fine again
I am not sure the app is protected this way, I'm building another test app to try performing a confuse deputy and see if the declaration of the custom is just enough.
Hope this can help somebody that was getting mad like me!
I had this problem in the Android emulator, and it was solved by going to Tools->AVD Manager, selecting the device, right click "Cold Boot Now".
The solution which helped me is to click on attach the debugger to android Process and set debugger to java.
Just throwing my experience in as this just started happening. With regards to all these answers, I tried a few of them and none seemed to work. So I started from scratch:
Initial setup:
- USB Debugging ENABLED
- Always prompt when connecting to USB (I usually only connect in charge mode)
- Allow ADB debugging in charge only mode ENABLED
- Wait for debugger DISABLED
- Verify apps over USB ENABLED
The steps I took to get debugging back:
Close down Android Studio - I didn't go so far as to delete the .idea folder as discussed, but I'm sure it couldn't hurt.
DISABLE USB Debugging
Revoke USB debugging authorizations
Reconnect Device
$ adb devices
> <Device Id> unauthorized
ENABLED USB Debugging
Reconnect Device
When prompted select ALLOW (I clicked always allow)
$ adb devices
> <Device Id> device
Open Android Studio and hit debug - Application started successfully, I was still getting 5-6 of these messages but then it worked:
$ adb shell am start -n "com.exampleapp/com.exampleapp.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -D
Waiting for application to come online: com.exampleapp.test | com.exampleapp
Waiting for application to come online: com.exampleapp.test | com.exampleapp
Waiting for application to come online: com.exampleapp.test | com.exampleapp
Connecting to com.exampleapp
Connected to the target VM, address: 'localhost:8600', transport: 'socket'
React Native
As a side note - this happens every so often, I'm not sure whether it's from switching back and forth between running from react-native run-android or debugging in Android Studio, but regardless I've had to do this a couple times (finally decided to document).
Also remember
$ adb reverse tcp:8081 tcp:8081
and to start the packager when debugging (I tend to forget).
Try to restart ADB. Execute terminal commands:
adb kill-server
adb start-server
I had this problem and none of the solutions provided worked for me.
I you had the same issue, you can also try this:
Edit Run/Debug configurations
Select the 'app' or other name's configuration
At the launch Options, change Launch "Nothing" to "Default Activity".
Steps

My Application can't start debug mode in Android Stduio

The logcat show:
Waiting for device.
Target device: lge-nexus_4-01aa55d2b923e7a9
Uploading file local path:
C:\Users\HOXCN\AndroidStudioProjects\Horcrux\app\build\outputs\apk\app-debug.apk
remote path: /data/local/tmp/com.hoxcn.horcrux
No apk changes detected.
Skipping file upload, force stopping package instead.
DEVICE SHELL COMMAND:
am force-stop com.hoxcn.horcrux
Launching
application:com.hoxcn.horcrux/com.hoxcn.horcrux.ui.activity.SplashActivity.
DEVICE SHELL COMMAND:
am start -D -n
com.hoxcn.horcrux/com.hoxcn.horcrux.ui.activity.SplashActivity" -a
android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN
cat=[android.intent.category.LAUNCHER]
cmp=com.hoxcn.horcrux/.ui.activity.SplashActivity }
Warning:
debug info can be unavailable. Please close other application using ADB: Monitor, DDMS, Eclipse
Restart ADB integration and try again(PS: I restart the adb with adb kill-server, don't work)
Waiting for process: com.hoxcn.horcrux
If i create a application with a default, the debug mode can run.
If i click run 'app', it work; if i click debug 'app', it show the message above and the screen show the dialog "Waiting for debugger" all the time
You hava to remove android:debuggable="true", because when you run/debug an application in Android Studio is signed with a debug certificate so that setting is not mandatory.Then check from console if the device is correctly attached with an adb devices. You should see it listed.
Below steps follow:
close Android Studio and any other IDE you have opened (maybe you have Eclipse also running?) and emulator instances;
Remove USB cable from PC;
3 . Run adb kill-server from console;
4 .Open Android Studio;
5 . Click on run/debug;
6 . when the window to select the device appears, attach your device to USB and USB to your computer;
enter link description here
Ok, this has happened to me. This usually occurs if you already have an apk with the same package name but different signature installed in your device. So the way to fix this is to uninstalll any existing apk's in your device.
Now in some android phones there are options for multiple user accounts and as such if an app is uninstalled it sometimes remains there for the other users. So you should go to the app options in the settings and scroll down to the very bottom. It might show your app at the bottom. Uninstall it from there too and it would work.
There is a Debug icon on the toolbar. It is located right next to the Run icon. Try to launch the app with that.
There is also a debug flag in the AndroidManifest.xml file. It is located under the application tag, and should be set to "true", as follows:
<application android:debuggable="true"> </application>
OR
Go to Tools => Android => disable adb integration and again enable it
after, Unplugged USB from device and again plugged in. Then press shift + F9
on Mac, I had the same problem.
I had an application to transfer files from my android device, this application causing the problem. All I had to do was to uninstall the androidFileTransfer application and install it again.
Good luck!
You can try to Restart your android studio and Reconnect your device..Its worked for me
Thank you

Unable to debug in android studio (Error running app: java.lang.Error : no Connectors loaded. Check your JDK installation.)

I am using Android studio 1.02 on Linux Mint. I was able to successfully debug my code on android emulators and my device LG G2 till yesterday. Today when I started my workstation I cant 'debug' my code.
It says:
Error running navigationbar: java.lang.Error : no Connectors loaded.
Check your JDK installation.
On my device I can see the message:
Waiting for the Debugger
Application NavigationBar (com.example.test.navigationbar) is
waiting for the debugger to attach.
and following are the console messages
Waiting for device. Target device: lge-lg_My_DEVICE'sID
Uploading file local path:
/path-to-apk/apk/navigationbar-debug.apk
remote path: /data/local/tmp/com.example.test.navigationbar
Installing com.example.test.navigationbar DEVICE SHELL COMMAND: pm
install -r "/data/local/tmp/com.example.test.navigationbar" pkg:
/data/local/tmp/com.example.test.navigationbar Success
Launching application:
com.example.test.navigationbar/com.example.test.navigationbar.NavigationBar.
DEVICE SHELL COMMAND: am start -D -n
"com.example.test.navigationbar/com.example.test.navigationbar.NavigationBar"
-a android.intent.action.MAIN -c android.intent.category.LAUNCHER Starting: Intent { act=android.intent.action.MAIN
cat=[android.intent.category.LAUNCHER]
cmp=com.example.test.navigationbar/.NavigationBar }
Waiting for process: com.example.test.navigationbar Can't start
debugging.
As advices on some older posts. I have already tried :
android:debuggable="true"
Restarting android studio and my PC
Uncheck and then select again 'Enable ADB integration'
Try to debug on emulator(gives the same problem)
Make a new program from the android-studio's templates and try to debug it
On the other hand if I 'run' my application. It gives no such error.
Finally, if I run android.sh form my terminal then I get this message after I choose my device:
java.util.ServiceConfigurationError: com.sun.jdi.connect.Connector:
Provider com.sun.tools.jdi.SunCommandLineLauncher could not be
instantiated java.util.ServiceConfigurationError:
com.sun.jdi.connect.Connector: Provider
com.sun.tools.jdi.RawCommandLineLauncher could not be instantiated
java.util.ServiceConfigurationError: com.sun.jdi.connect.Connector:
Provider com.sun.tools.jdi.SocketAttachingConnector could not be
instantiated java.util.ServiceConfigurationError:
com.sun.jdi.connect.Connector: Provider
com.sun.tools.jdi.SocketListeningConnector could not be instantiated
Kindly advice steps to resolve this issue.
Thanks
Some links I already tried:
Not Able To Debug App In Android Studio
Finally I uninstalled my JDK8 and installed JDK7 this time.
Then if I open Android-Studio. It gave the errors that 'jdk8 not found'.
Upon this I typed :
rm -R -f ~/.AndroidStudio/
To delete all the settings related to Android-Studio.
Now when you run Android studio it will ask you to install/initialize it again.
That worked for me!!
Note: Till now I was working comfortably with JDK8. Only today due to some change I got the error.

Categories

Resources