I have a real Android device that I am using to debug. In order to attach Android Studio to my application, I ran this on the device:
adb shell am set-debug-app -w my.package.name
This worked fine. However, the problem is that now, whenever I try to open the application on my device, it will wait for the debugger to attach.
Waiting for Debugger
My Application (my.package.name) is waiting for the debugger to attach.
This happens even after I disconnect the device from my computer. Also, I restarted my device and nothing changed.
This is definitely not related to Android Studio, because my device is not connected to Android Studio, so any solution involving restarting Android studio would not work.
After looking at this page, I tried:
adb shell am force-stop my.package.name
This stops the application. But when I reopen it, it still waits for the debugger to connect.
So, any idea how I can remove this debug hook?
You can set/clear the debug app through Developer Options in your device settings.
If you want to do it through adb, it looks like you could do am clear-debug-app to clear it: http://androidxref.com/8.0.0_r4/xref/frameworks/base/services/core/java/com/android/server/am/ActivityManagerShellCommand.java#166
case "set-debug-app":
return runSetDebugApp(pw);
case "clear-debug-app":
return runClearDebugApp(pw);
Related
I have searched the internet and tried everything I have come across, but I cannot figure out what I am doing wrong. I cannot attach the debugger to my Android process in Android Studio.
I have built an app in Android Studio 2.3.3 on a virtual machine using VirtualBox and running Ubuntu 16.04.2. I have installed the app on my device, a Getac Data Logger, and have noticed that my app opens for a couple of seconds, displaying a blank white screen, and then crashes. So, I have attempted to debug the app on my device to find the problem. When I click on the "Attach debugger to Android process" icon, I can see my device as an option, however, when I select my device the OK button is grayed out. There is no way for me to move forward with this process. Sometimes the warning "debug info can be unavailable, please close other application using ADB: Monitor, DDMS, Eclipse" pops up, but not every time.
Does anyone have any ideas as to what I am missing? Does it have something to do with the limitations of working on a virtual machine?
Things I have tried:
Making sure I have allowed USB debugging on my device
Selecting all kinds of combinations of show all processes/auto/java/etc
Commands: adb kill-server, then adb start-server; adb kill-server, then adb -P 5038 start-server
Waiting to plug in my device until I launch the debugger attachment
Building debug variant
Adding android: debuggable="true" to my application in my AndroidManifest.xml, then noticing it was not necessary after building the debug variant and taking it back out
Disabling and re-enabling the ADB integration through Tools/Android/Enable ADB integration
Closing Android Studio and then opening it again
Changing the adb port
Invalidating cache/restart
Uninstalling the app, clean build, reinstalling the app
Installing the MTP using the command: apt-get install mtpfs. It says that mtpfs is already the newest version, but the Ubuntu error "Unable to open MTP device '[usb:001,021]'" does persist, just not always.
Revoking USB debugging authorizations, exiting out of Android Studio and my VirtualBox, rebooting everything, and setting it all up again.
PLEASE NOTE:
I am brand new to development (a little over a year experience in web development), brand new to app development (this is the very first app I am creating), brand new to Android Studio (again, very first app).
My device is showing up in the debugger as an option. It is just that the OK button is grayed out, no way to move forward.
I do NOT have Eclipse or Monitor (and therefore not DDMS either) running.
EDIT: I have noticed that "#com.android.ddmlib - Adb rejected connection to client '[numbers]': closed" is showing up in my terminal several times with several different number combinations. Not sure what this means. Perhaps I am running DDMS? I thought that was something that runs through Monitor?
Unplug your phone from your PC. Then plug it back in. On the pop-up, make sure you set it to “Media Sync (MTP)”.
I had intellij Idea IDE and Android Studio 4 Canary were open with Android projects at the same time, after closing both the IDEs and opening only android studio, I was able to attach the debugger to the app process.
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.
Seriously going nuts with this.
I don't want a solution that tells me to restart eclipse or anything slow like that. Killing adb and restart eclipse is obviously going to work. But am I supposed to waste 1 full min restarting adb just to upload an APK and do some testing?
What happens is I upload apk in eclipse by clicking debug, then I unplug my device to do testing. Because after unplugging, the device run much faster than plugged.
Every single time I unplug my device, I run into this problem on Windows. Doesn't happen on my Eclipse on Mac.
Solution1
run this command: adb uninstall com.yourpackagename
Solution2
This is not an answer to solve problem with unplugging.
However, if you set android:debuggable="false" in your manifest, then running your android in release mode with the wire plugged in is quite fast.
So if you don't switch devices, u don't need to unplug your device then.
it is 10x speed up vs running in debug mode.
Until yesterday everything was working perfect until today that I connected my phone (just updated to Jelly Bean) and adb.exe stop working. If I execute adb.exe I can see the help but when I want to use any command it just run forever and no message is shown.
I tried with "kill-server" and "devices" and it runs forever, no message at all is displayed and I must terminate the process to close it.
I just connect the same phone to other PC that was fully functional and also adb.exe stop working. The strange thing is that adb.exe will not work any more even If I disconnect the phone and/or I connect my tablet. Adb.exe just got useless.
I was using the same phone yesterday (android 4.0), with my tablet (android 4.2) and adb.exe was working.
Adb.exe is not corrupted as I checked it MD5 and it is the same as in working pc (5787e5df1a68e7afea82d58e5f0d6549 *adb.exe).
I have Android Debug Bridge version 1.0.31 and Android SDK tools 22. I uninstalled android sdk tools and Installed again but when is near to finish it hangs because it launches adb.exe and again it will run forever.
Please any suggestion or help?
Try rebooting. Sometimes the USB drivers lock up. I work HEAVILY with ADB in my project at http://android-casual.googlecode.com and I find it to be one of three things when ADB locks up.. 1. USB drivers, or 2. adb_usb.ini needs an update, or 3. on new devices you have to "pair" them so that ADB can perform any action.
To pair, you can disconnect, reconnect and run "adb devies" to display the pairing on the device.
Not sure if you're still facing this issue, but for what it's worth I had the same kind of issue with adb.exe, and came across this post while trying to troubleshoot it. In my case, I wasn't using any physical Android devices, only the Emulator. Everything had been working fine and then suddenly adb.exe would no longer respond (couldn't get any output from any adb command - it just appeared to hang).
In the end, my issue turned out to be another application I had installed on my development machine. It was starting as a service, and was listening on the exact same port that the adb server runs on (5037), which appeared to be confusing it. Once I changed the application to use a different port, adb started working again and everything was fine.
Run command
where adb
I had such kind of situation.
In my case
where adb
gave output
C:\Windows\adb.exe
D:\AndroidSDK\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe
I tried to run adb from disk C, when Eclipse used second adb from AndroidSDK (from disk D).
I removed adb from strange path C:\Windows\adb.exe, and this solved this problem.
I got the same problem,my solution is going to cmd and paste adb.exe path,and then click enter button.For example
D:\Android\Android\platform-tools\adb.exe
After I start the emulator by hitting Debug in Eclipse, after certain time it disconnects from the ADB, but the emulator stays open. It is responsive, I can navigate and start apps.
How can I attach back the emulator to ADB, to be able to debug from Eclipse?
(the current workaround is the terminate the emulator, close Eclipse and restart both of them, which takes 10 minutes as you know the emulator needs time to start up)
EDIT 1
Check out this image:
EDIT 2
After I kill and restart server. One emulator process shows up in Devices tab in Eclipse. But that cannot be expanded, and I don't see sub-processes.
I can't hit debug already, as it says: Debug already running. (How to I stop the debug?)
If I managed to start the debugging of another project, It hangs out in the emulator telling me: Waiting for the debugger to attach. Nothing happens.
As you said, the problem is not Eclipse losing contact with the Emulator, but ADB - the Android Debug Bridge - losing contact with it. As Eclipse uses ADB to communicate with the emulator when ADB is broken Eclipse can do nothing.
To fix this stop the ADB server by running the following command:
adb kill-server
Eclipse will then usually try to restart ADB, or you can restart it yourself by running an ADB command, such as:
adb devices
If you do, you'll see output like this:
* daemon not running. starting it now *
* daemon started successfully *
List of devices attached
emulator-5554 device
You can also do this via the mouse, using the Reset adb option in the Devices view in Eclipse.
It's also worth noting the Console view has two modes, DDMS and Android. You're usually in Console mode but it's DDMS mode which will show ADB status messages. Select modes by clicking the button with the Monitor icon, or using the arrow next to it:
If all else fails, try killing the adb processes from the OS. On Windows XP I use:
TASKKILL /F /IM adb.exe
There is an easier way. From eclipse you can reset the adb from DDMS panel.
Here's a short video on doing that "Reset ADB on DDMS"
Here's a quick screenshot of where you can get the option.
Sometimes a kill-server won't help at my machine (WinXP). For example I can't see the emulator in the DDMS-View any more or I do see it but no processes running on it.
In these cases I close the emulator and eclipse and manually kill the adb.exe-process from the process list.
When I then restart eclipse and the emulator, everything's fine again.
Now I just need a keyboard-shortcut for that :-)
on a mac, i just had to kill adb from activity manager and manually re-open the program again. had eclipse open all through and it worked just fine.
Try with adb kill-server and adb start-server. Even then the same problem occurs kill your running process from ddms prespective. Refer this link(http://www.jiahaoliuliu.com/2011/02/stopping-android-applications-already.html). This solved my issue. Hope for you also.
I am testing an application on an Android 4.0 (API level 14) emulator and once I run the app the emulator starts up and as soon as it loads, Eclipse DDMS disconnects from the emulator.
Here is the workaround that I am using: Open terminal, navigate to platform tools (C:\android-sdk\platform-tools\ or wherever you have your android-sdk installed), and run adb kill-server, and then run, adb start-server. DDMS should now list the emulator - from Java perspective, right click on the app -> Run As -> Android Application.
Hope this helps.
My handy bash script
#!/bin/bash
./path/to/adb kill-server
./path/to/adb start-server
./path/to/adb devices