Unable to attach debugger in Android Studio in MacBook - android

I am unable to attach debugger in Android Studio in MacBook. I am getting this error
Failed to start monitoring <deviceID>
I have tried multiple solutions :
Turn on/off usb debugging on device
Invalidate cache/restart Android Studio & Build -> Clean project
Stop and start adb server from terminal
Changing cable/usb port
Reboot Android device, Mac
Reset Android device
Upgrade gradle plugin & Android Studio to new version
Setup:
Macbook,
Android Studio 4.2,
Pixel 3a Android 11
OnDevice USB Preferences:
USB Controlled by: This Device
Use USB For: No Data transfer
I was able to work with the debugger fine for a very long time (~8 months) but it stopped abruptly few days ago and did not have any luck since then.
I have tried various solutions from stackoverflow, medium most of them fall under the things I have tried above and I have observed that the solutions are for Windows machines, so wondering if there is anything different for Android Studio on Macbook?
Appreciate your time looking into this. Thanks in advance.

Related

Android Studio Disconnects From Physical Device

Android Studio Bumblebee (2021.1.1) was released stably on 25 January 2022 bundled with a new Device Manager (accompanying new support for Android 11+ device debugging over WIFI). I jumped on this stable release, updating from Android Studio Arctic Fox (2020.3.1 Patch 4).
Unfortunately however, since updating, physical devices/handsets don't remain connected to Android Studio for the purpose of debugging. I can confirm that the issue was introduced from Android Studio Bumblebee onwards (occurring in Beta and Canary builds also). I've reproduced the issue on Android Studio Bumblebee (Stable), Chipmunk (Beta), and Dolphin (Canary), but Android Studio Arctic Fox (superseded Stable) continues to work just fine.
The issue occurs soon after opening Android Studio (Bumblebee+) with one of my physical devices connected. Everything appears fine initially and I may even have enough time to deploy my project to the handset, before the device disappears from Android Studio (as if I'd physically disconnected the USB cable from my computer or from the handset itself).
I've tried a fair few things in an attempt to determine a root cause. These include testing:
With different USB cables.
With different handsets (both varying makes and models).
With various versions of the Android Studio IDE (as mentioned above).
Plugging the USB cables into different USB ports on my computer.
Rebooting handsets and my computer.
Restarting Android Studio.
Invalidating caches and restarting Android Studio.
adb kill-server then adb start-server.
Revoking/reaccepting USB debugging authorization.
Reinstalled build tools/platform tools, and ADB.
A great number of further possibilities, to no avail.
I searched and read through remotely similar issues, including (but not limited to) these:
Android Studio Arctic Fox (Adb) - Connected Devices are being disconnected after some time
Android debugger continually disconnects
This particular comment in one of the above issues clued me onto a possible root cause:
I have been fighting for a few days with adb not seeing my device. After trying many other posted solutions, I discovered that the issue was with Chrome also trying to connect its debugger to a web view. If Chrome is connected using chrome://inspect, then adb seems to disconnect. Quitting Chrome resolves the issue. Then I can connect with Android Studio and then restart Chrome and reconnect. Hope this helps someone else.
However I've been unable to do anything with the above discovery, other than close Google Chrome, and hope for the best. Obviously this isn't an ideal solution. It appears as though the moment Google Chrome shows the connected physical device in the chrome://inspect/#devices page, the physical device promptly becomes unavailable through Android Studio.
I've jumped back to Android Studio Arctic Fox (2020.3.1 Patch 4) for the moment, however this brings with it other issues (my current core project targets the latest SDK version, which requires the updated IDE).
Absolutely any help with this would be insanely appreciated. I've exhausted just about every avenue that I can think of!
I solved the problem by disabling
Settings -> Build, Execution, Deployment -> Debugger -> "Enable adb mDNS for wireless debugging"
I'm developing for android for almost 10 years now and I'm struggling with this annoying issue regularly - while debugging with android studio and a physicals device the device suddenly disconnect with no apparent reason.
sometime it gets into a loop of disconnect/reconnect for a few times
During the years I change PC, Devices, cables - but always at some point the problem persist.
I think there are many reason for this problem, including:
Bad/old cables
Erosion of the USB socket of the PC or the device
bugs in ADB/Android Studio/Android device
I tried to work with WIFI plugging, most of them didn't work, the one who did work, solve the issue, but were ridiculously slow
I search the web many times and couldn't find an answer that solve the issue for me, partly because there are many different reason for this, which makes each answer very specific.
Therefore I suggest that if any body find a solution for his specific case, please add it as an answer here for the the benefit of other.
Currently I found the following solution: after I bought many cables, I was finally able to find one that doesn't disconnect as much (I actually borrowed it from my work...)
AND I also use Vysor, which project the android screen to my PC, so that I don't have to move or touch the Physically device, which reduce the problem to almost never.
I also noticed that it happens more when the battery is 100% so I try to keep it below
SOLVED this with changing usb on pc from USB 3.0 port (blue type) to USB 2.0

Android Studio in macOS does not recognize physical device after hitting 'run'

I have been testing my Android app in my Samsung Galaxy S8 for the past few weeks from Android Studio's ADB without any issues.
After a while a switched to test the app in Android Studio's built-in emulators.
Then I swiched back to test it in my Samsung and it won't install the app.
I would plug the phone to the laptop, Android studio's ADB would recognize the device, I hit run, and after the Gradle build, as soon as it goes into 'install', the process stops, and prints the following:
10/16 14:34:46: Launching 'app' on samsung SM-G950F.
Installation did not succeed.
The application could not be installed.
List of apks:
[0] '/Users/david.rajchenberg/Desktop/JByte Studios/Practice/SpeechToText-master/app/build/outputs/apk/debug/app-debug.apk'
Installation failed due to: 'device 'ce031713eb784b1f03' not found'
Retry
I have tried the following:
Uninstall and reinstall Android studio
Turn off and back on my device
Switch USB cables (I only have so many)
Switch USB ports
Clean project
Build project
Unplug and and plug back in the device and wait until Android Studio recognizes it again
I checked the phone's connectivity to the laptop and its okay. I am able to move files in and out of the device, to the computer and back.
Developer options is activated with USB debugging
To summarize
Android Studio recognizes the device as soon as I plug it into the laptop, but as soon as I hit run and gradle is done building, as soon as the process goes into install, the connection between Android Studio and the device is lost, while the device, is still connected to the computer (and able to move files in an out with ease).
I run Android Studio 4.1 on a MacBook Pro with macOS Catalina 10.15.6
Any assistance would be highly appreciated.
Thank you,
Turns out I needed to kill the adb from Activity Monitor (Mac) and restart Android Studio. Apparently that did the trick

Android Studio: Running application in emulator not working

Today I downloaded Android Studio for my Debian Testing system. I wanted to run a HelloWorld application but weren't able to run it. With adb I can install it without having any problems.
However, if I try to do it with Android Studio, it gets stuck on 'Installing APKs'. The same happens when I try to start it in an emulator (gets stuck on 'Waiting for target device to come online').
My device is a Samsung Galaxy S3 with LineageOS (Android 7.1.2) and root permissions. Android Studio recognizes my phone properly.
What I've already done:
installed openjdk
set android_home
installed all the SDK-platforms since Android 4.3 and Android Emulator from SDK tools
enabled USB-debugging
tried with MTP and PTP
tried another emulated phone
installed lib32stdc++6
restarted my computer
and probably much more
I tried to do it the whole evening and couldn't find a solution. Is there something Debian-specific because I can only find instructions for Ubuntu? I have never experienced anything close to this on other systems.
Thank you in advance.
EDIT: I am now able to use my phone to run the android application by using USB 2.0 instead of USB 3.0! Is that a normal behavior since it works with native adb? I mean, if I buy a new PC after some years which has got only USB 3.0 ports, will I not be able to use phone debugging with Android Studio or is this just an issue? It is still known since 2014 (https://stackoverflow.com/a/9548311/8292104).
However, I still cannot get the app running on an AVD. I changed graphics to software, now it shows the phone but the screen remains black and the phone won't start. What can I do to fix it?
Try to completely delete and install Android Studio again, I think that it will solve the problem
Another possible solution that worked for me is to, in the application, go to
app - build - intermediates - split-apk - debug - slices
and then delete all of the contents within this folder. Then again, this only worked for me, so I would duplicate the document in case of corruption.

ADB connection with Android emulator breaks

I am trying to connect with android emulator using ADB. I can connect with device but every time after a while ( about 10 seconds) connection breaks.
I used to work with adb some time ago and everything was correct.
I tried to restart adb, reinstall adb, I checked settings of emulator and still there is problem.
Check your Android Studio version is the latest, I had this problem on Mac when Nougat was just released. You can try the dev channel if the stable channel doesn't work
Switching Android Studio build channle: http://tools.android.com/preview-channel

Running an OpenGLES app on mac iphone emulator fails

I set up the vcremote correctly(https://msdn.microsoft.com/en-us/library/mt147405.aspx#ConfigureVS) and it connected. I tried to run the default visual studio OpenGLES app on the iphone emulator through vcremote and it built the app just fine, but just as the emulator opened it crashed with the following error:
"Unable to start debugging. Unexpected LLDB output from command "-target-select remote localhost:3031". Command 'target-select'. Fn 'Target select' failed"
I have no idea how to fix this, and it seems that there are not a lot of people running into this problem. Any help would be much appreciated, even if it just helps me understand the error message better, SOMETHING!
I had been struggling with this problem for hours and hours until I found the following link:Remote Debugger Port Assignments
The Visual Studio Remote Debugger can run as an application or as a
background service. When it runs as an application, it uses a port
that is assigned by default as follows: Visual Studio 2022:
4026 Visual Studio 2019:
4024 Visual Studio 2017:
4022 Visual Studio 2015: 4020 Visual Studio 2013: 4018
Visual Studio 2012: 4016
The port 3031 seems to be coming from out of the blue!
I am using Visual Studio 2017 so I used the following command to start up vcremote:vcremote --secure false --nativeDebugProxyPort 4022
After that the iPhone simulator and App started up, but the debugging started to work only after restarting the App during the debug session (which I did by rebooting the iPhone simulator).
I still did not get the pairing working on a secure connection yet :-( Any hints are welcome!

Categories

Resources