Debug Installed App - android

How can I debug an app that was built with debugging turned on but is already installed on a phone?
I have tried to find a way to attach Android Studio to an existing app, but can't figure that out. Do I need to use adb in some way to do this? Any hints would be appreciated.

Click in the fourth button in the bar (This is screenshot is from AndroidStudio 2.2, the icons have changed but the position is the same).
After that, it will prompt to you all running application that can have debug attached, just select it and you are now debugging.

Related

Is it possible view entire logcat of Android device (i.e. not attached to a specific process)?

Simple question, but is it possible to view the entire logcat output of an Android device in Android Studio? Meaning all of the logs from everything that's happening on the device, not necessarily only those generated by the app in development.
I ask because I have a bug that does not show up on the debug build (i.e. I build it in Android studio and run it on a device), but it DOES show up in the production build for the same code, and I would love to see what is happening on the device.
Essentially, I'm asking if it's possible to select nothing from the following dropdown menu.
Use no filters option in your Android studio Logcat.
How you can select nothing in processes spinner:
Stop your application
Close the emulator
Press launch in android studio
Cancel launching the application
Emulator is still launching
You have no debuggable processes in your spinner.

Android Studio: debug an already running application without restart

Is it possible in Android Studio to debug an already running application without restarting it (assuming the application was previously installed through Android Studio)?
Follow this step (I assume that you have connected device and USB debugging option is turned on):
Step 1 : Click on Attach Debugger option.
Step 2 : Now dialog is open, select the process you want to run.
There is a button1 besides run and debug ones to add debug to your running app. You have to run the debug build to be able to do this.
Yes you can. Just click on the button highlighted in the given image
After clicking this image select the process, running on any attached device, which you want to debug.

Application is waiting for the debugger to attach

I,m working in eclipse to develop an android app and when i tried to debugged on my samsung tab, i got the following msg on its screen "Waiting for debugger" and beneath it was written "application xxx is waiting for the debugger to attach ", I did some search and found to:
See target sdk
Restart eclipse and device
Update eclipse
Uninstall app from device and install again
I tried all this, but nothing helped. Kindly help me.
In my Nexus 7 Tablet running android 4.4.2
I solved this problem by going into
Settings
Developer options
Select Debug app
was selected , Select Nothing
Done!
Sometimes "force to close and open again" doesn´t work, so this problem could be present when the application is currently in debug and is selected to be debugged, then from your device go to:
Settings ->
Developer options ->
Select app to be debugged ->
Select Nothing
or when the application is supossed to being in "debug mode" but is not selected as be debugged :
Settings ->
Developer options ->
Select app to be debugged ->
Select the application!
I had same issue. Adding permission didn't help me, because Eclipse automatically enables debugging when it runs in debug mode.
Check your device setting whether "Wait for debugger" is unchecked under "Developer Options".
Also I tried closing and restarting Eclipse, and finally it worked!
I'm still figuring out what the real problem is, but hope this helps!
Restarting Eclipse is the only solution which works every time for me.
Go to Settings->Developer options.
And then just turn off and on check box right to the Developer options title.
Also toggle USB Debugging again.
Worked for me
I was having same problem with my emulator.
What i did is,
Close the emulator
Open AVD manager
Wipe Data from dropdown for the required emulator in AVD Manager. May be same thing work for devices also.
This has been asked before. It is uncommon, but some devices need an extra permission(flag) to let the debugger attach!
So open your androidManifest.xml and add this permission:
<uses-permission android:name="android.permission.SET_DEBUG_APP"></uses-permission>
Another reason for this dialog to hang there is when you have breakpoints in different processes of your components (application / activity etc...).
For example:
If you have a breakpoint in an activity that runs on a different process than your main application you will see this dialog until you attach the debugger to the process manually.
For android studio it will be using the icon in the middle:
The intuitive reason for this will be that when you run in a debug mode the debugger is attached to your main application process and not to all your other processes, thus you need to specify manually to which process you want to attach your debugger.
I had this problem when I press only F11 to Run.
Pressing F11 does debug. In order to run, press Ctrl+F11.
I haven't ever seen this problem after do like this.
I ran into this issue on Android Studio 2.0 with a Nexus 6 running 6.0.1.
I tried most of the suggestions above and finally fixed it by restarting both Android Studio and my Nexus 6.
I had this same issue and eventually found that in AndroidManifest.xml the Application element had the following attribute:
android:debuggable="false"
I changed this to
android:debuggable="true"
And the debugging then worked correctly.
I had the same problem with my Samsung S4 mini: after hibernating my pc with running eclipse, my phone couldn't connect with the debugger anymore. Restarting phone and eclipse didn't work.
I found, that my eclipse "disabled" the debugger in the android devices view: Window menu -> Show View -> Other -> Android -> Devices (also called DDMS view)
There was a red bug in front of my device. I enabled debugging by pushing the green bug button and now debugging works fine. This also works, if there is no bug in front of your debugging device.
It's also good to investigate port 8700 (the DDMS "base port", a port forwarder). When TCPView shows that this port is kept by process "", it's impossible to connect to ADB and debug. This process can't be killed nor terminated in TCPView. After logging out of Windows and logging in again, this port is free again. After starting AndroidStudio/IntelliJIdea this port is owned by process "idea64.exe" and its possible to debug.
When application crashes and AndroidStudio is restarted without stopping debugger (which also detaches from ADB), it may happen that port 8700 is not released, blocked by process "".
TCPView: https://technet.microsoft.com/en-us/library/bb897437.aspx
http://developer.android.com/tools/debugging/ddms.html
I got this error even when the USB was unplugged, and the app wouldn't start.
The only thing that worked for me was restarting the Android device.
I found this simple solution to it. Just click on the debug panel tab at the lower potion of your eclipse or wherever it is. Tada!! It works! It seems eclipse is getting old it needs a slight nudge. Works every time for me!
I got stuck with this when I tried to debug from IntelliJ cause I had both IntelliJ and Android Studio open.
Even if there where no debug-process going on in Android Studio, I was able to launch debug from IntelliJ after I closed Android Studio.
Restarted the Android Studio but that didn't help. Unplugged the device from USB and plugged it back in which did the trick for me, no changes needed in Developer options in the phone settings.
I have tried the following to no avail:
Restart the Android device.
Turn Developer options off/on under the Settings of the Android device.
Disable/enable USB debugging.
Restart Android Studio.
It started working after: Android Studio > File > Invalidate Caches/Restart...
For me it was when two different Android Studio were launched simultaneously
It's normal message when you debugging your application. Just wait for several seconds and app will start.
Simply force to close then, open it again :)
Edited:
force to close the application, and then go to menu and start the application by clicking on the apps icon

"Waiting for debugger to attach" showing even when not running in debug mode

My problem:
I ran upon an awkward problem as I was developing my application. As mentioned in the title, every time I install my application (in run mode, not debug!) at start-up the waiting for debugger to connect.. message appears for 1-2-3 seconds, and the application starts.
What I want:
What I would like is to be able to start the application without that message appearing (it only started appearing in the last few days, and I can't remember changing anything related to debugging).
What I've tried:
I have tried setting the android:debuggable="false" but if I do this the debugger never attaches and the message never disappears.
I have also tried after installing to disable USB Debugging, but still no results.
Even if I kill the application and wake it up through an external source (it uses Google's C2D Messaging Framework) it still tries to run in debug mode on wake-up.
I have developed several Android applications and never stumbled upon this. Why wouldn't I be able to start the application in RUN mode? Is there any other way to install the application on the device, without hitting the run button in Eclipse?
I can post code-snippets from the AndroidManifest or from other parts of the code if necessary, but as I already mentioned I wasn't getting this kind of weird behavior several days ago.
Make sure your java files dont have any break point and Restart the device every thing should be normal.
I was experience the same problems where my application was always being run in debug mode. Restarting the device did the trick for me.
and make sure you are using
right click on project-->>Run As -->> Android Application
For me the solution was turning off the USB debugging from my device settings, and then turning it on again!
Much quicker than restart the whole device.
I had the same problem using Android Studio. Restarting my cellphone worked for me!
1. Open setting in ur phone.
2. Go to developer options.(About Phone-> Developer Option).
3. Disable the Developer option and again enable the Developer Option.
4. Enable USB debugging and Install via USB.
Run this command and the issue will be resolved
adb shell am clear-debug-app
Check if the option waiting for debugger is actived.
Settings -> Developer options -> Wait for debugger.
I think this it is new from Jelly Bean.
I'm assuming this is in the emulator and not on a device. If it is a device, ignore the rest. :p
It sounds like you saved a snapshot of the emulator as the debugger was connecting.
To fix:
1) Go to the AVD control panel, click on the emulator that's affected and hit start
2) when the window pops up, de-select "Launch from snapshot" and leave "Save to Snapshot" selected
3) Start the emulator.
4) Close the emulator
5) On the AVD control panel again start the emulator
6) Check "Launch from snapshot" again
That should fix things up.
EDIT.
Sorry for the wasted space, I read too fast and missed you talking about trying disabling USB Debugging. I have run into the above situation I describe before so I'll leave this answer posted for those who come along who do have such an issue.
"Wait for debugger"in Developer options may have been set to wait your application.
Do check once that you placed breakpoints. Run app once and if you get the same message do debug as-> debug configuration-> select the app which you need to run and select always prompt to pick device.It will work for sure. It may be stupid, but i faced this problem for a long time and i tried this and this helped me. And if needed restart your device. Thanks
For me, I use Android Studio 2.1.2I, I click on Menu Run > Attach debugger to Android process
There is only 2 lines
__device_name
____app_name
I just select app_name(want to run) and click OK then miracle happens.
I had the same problem.
But restart my Device or clear the Breakpoints don't worked.
I tried :
Run --> Attach to Android Process.
Select your package and press OK.
and it works :)
There was so many adb processes running ,I kill them all and its start debugging
You can also set your Android App as Debugging-App
Settings --> Developer Options --> set Debuging-App
there you can choice your app
You might have added your app in Select app to be debugged on your phone. In Settings -> Developer Options -> Select app to be debugged
To resolve this, go to Select app to be debugged and click on No apps
Your manifest file may contain following permission
Just remove this permission
<uses-permission android:name="android.permission.SET_DEBUG_APP"/>

while the apk runs without problems on emulator when installed on Motorola milestone picture and icon doesn't shown as they were on emulator

my problem : the app I have uploaded into my cellular device is shown without the pictures I have insert to it .
steps I have done in order to install:
I have inserted the xxx.apk file into the device via usb
I downloaded an apps installer via the Market
I opened the app using the installer and instead of picture an white background appeared
when I opened the xxx.apk file using file system I found the pictures.
note: even an application icon weren't appearing.
Apparently the res libary having problem to be bined to application.
I might ness to add something to my appliction manifest?
I might need to change something on my device ? (I already made a change and enabled user's not Market application )
I would be very grateful for some life saving answer I need to show my work in a few days in this is the first time i tested her on a real devise.
I also tried an example as shown in hello android book the same example worked perfectly on the emulator where on my android device (Motorola milestone ) the picture and icon weren't shown
Please tell me what I might be doing wrong guys I need to apply my project back at uni(I was the only one in uni who did it on android and in my country most of pep don't even know what android is so getting help outside of forum's like this is not an option ) so please please help me .
I don't know what app installer you downloaded from the Market, but you shouldn't need it. You should be installing the app to your phone using the same SDK tools you used to install it to the emulator. Ie, using Eclipse or the commandline "adb install" commmand.
I'm assuming you used the SDK tools to install the app to the emulators? In which case, start there. Start with looking at what you're doing different between when you installed unsuccessfully to your phone and when you installed to successfully to the SDK.
In my experiences so far, there should be very few differences between working with the emulator and working with the phone.
Well, something is wrong, but what is hard to tell from your question. What pictures are you talking about? Your drawable resources? My guess would be that your application works in the emulator (you have tested it?), but that it doesn't on the phone you're testing with. Have you checked the logcat output?
If you're developing from Eclipse, why not try a debugging session using the phone rather than the emulator?
Hard to narrow down without more details, but a few notes:
Pontus has a point - what's your logcat output? You can use logcat on a real device. Maybe not yours unless it's rooted, but with many phones you can.
Do you link the drawable to your app in the manifest file?
How do you test on emulator vs. device? Do you right-click the app and choose "Run As -> Android Application"? Do you do that for both emulator and device?
When you run on the device, do you first sign it? If so, can you verify the jar/apk and see the contents? Is the drawable under res/drawable?

Categories

Resources