Android: Where log cat goes while running on device? - android

I'm using Eclipse on mac for developing android apps.
When I run the application on emulator the log cat window shows what is expected and do work fine but when I run(or even debug) on real android connected device my log cat window doesn't show even a single line.
How to deal with log cat when running on real android devices?
Thanks,

You have to select the device in the DDMS environment, Windows tab, select "Devices", and then select your device, i.e. "HtXXXXXXX".

First, Is device really connected? To check whether the device is connected or not, just run adb devices on console. It will list all the devices attached to the system.
Second, just run the adb logcat command at the command prompt, it will display the logcat window separately.
While many devices are attached to a system, adb logcat will display the following message:
- waiting for device -
error: more than one device and emulator
so to resolve above case, you have to run the command with device id with -s option.
For example:
adb -s emulator-5556 logcat , this will display the logcat for emulator.

Try just to restart it when you connected to device.

Related

Unable to start the "HelloWorld" NativeScript app on an Android emulator [duplicate]

I'm having a problem with emulator-5554, it keeps telling me it is offline.
When I do a adb devices from the command line it says
emulator-5554 offline
Even after a fresh restart, I try that command and it still says it is offline.
The problem is when I try to install .apk files to the emulator using abd install <path> from the command prompt, it tells me that it is offline, if I create another device and run that one, then try to install the .apk files, it says I have too many devices connected. So in other words, I can't install my .apk files.
How in the world can I get rid of that damn emulator-5554? I heard that if you do a restart, it should clear all the devices, but that does not seem to be working. It is like it is getting initialized when my computer starts up. Has anyone run into this issue?
Thanks
1 . Simply "Wipe data" to fix this issue.
2 . If it doesn't work, go to emulated device and enable developer options > enable usb debugging
In such a case, you can do all of the following in order to be assured that your emulator starts working again :
Go to cmd and type adb kill-server
Go to task manager and find adb in processes. If you find one, right click on it and click on end process tree.
In eclipse, go to Window>Android Virtual Device Manager, click on the AVD you want to launch, click on start and uncheck "Launch From Snapshot" and then click on launch.
That's it! It will take a while and it should resolve your problem.
The way that Android detects emulators is by scanning ports starting at port 5555.
The number you see in the adb devices list (in your case 5554) will be one less than the port that adb is finding open.
You probably have a process running that is listening on port 5555. To get rid of the "offline" device, you will need to find that application and close it or reconfigure it to listen to a different port.
This solution is for Windows.
(See #Chris Knight's solution for Mac/Linux)
Start Windows Powershell:
Start -> type 'powershell' -> Press ENTER
Run the following command: adb devices
PS C:\Users\CJBS>adb devices
List of devices attached
emulator-5656 host
emulator-5652 host
12b80FF443 device
In this case, 12b80FF443 is my physical device, and the emulator-* entries are garbage.
Per #Brigham, "The way that Android detects emulators is by
scanning ports starting at port 5555.". The port number is indicated after the emulator name (in this case 5656 and 5652). The port number to check is the emulator port number plus 1. So in this case:-
5656 + 1 = 5657
5652 + 1 = 5653
So let's see which program is using these ports. In this case, the ports to check both start with "565". So I'll search for ports in use starting with 565. Execute: netstat -a -n -o | Select-String ":565"
PS C:\Users\CJBS> netstat -a -n -o | Select-String ":565"
TCP 127.0.0.1:5653 127.0.0.1:5653 ESTABLISHED 5944
TCP 127.0.0.1:5657 127.0.0.1:5657 ESTABLISHED 5944
The final field in this output is the PID (Process ID) - in this case it's PID 5944 for both of these two ports. So let's see what this process ID is. Execute: tasklist /v | Select-String 5944. Replace 5944 with the output of the previous command:
PS C:\Users\CJBS> tasklist /v | Select-String 5944
adb.exe 5944 Console 1 6,800 K Running MyPCName\CJBS 0:06:03 ADB Power Notification Window
What a surprise. It's ADB. As noted by other answers, it could be other programs, too.
Now, just kill this process ID. Execute kill 5944, replacing 5944 with the PID in the previous command.
PS C:\Users\CJBS> kill 5944
To confirm that the spurious emulator is gone, re-run the following command: adb devices
PS C:\Users\CJBS>adb devices
List of devices attached
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
12b80FF443 device
ADB re-starts (as it was previously killed), and it detects no more fake emulators.
From the AVD Manager try the "Cold Boot Now" option in the drop-down. It worked for me!
If you are on Linux or Mac, and assuming the offline device is 'emulator-5554', you can run the following:
netstat -tulpn|grep 5554
Which yields the following output:
tcp 0 0 127.0.0.1:5554 0.0.0.0:* LISTEN 4848/emulator64-x86
tcp 0 0 127.0.0.1:5555 0.0.0.0:* LISTEN 4848/emulator64-x86
This tells me that the process id 4848 (yours will likely be different) is still listening on port 5554. You can now kill that process with:
sudo kill -9 4848
and the ghost offline-device is no more!
On macOS Big Sur and later, use
sudo lsof -i -P | grep LISTEN | grep 5554
to find out the process.
I finally solved this problem,
I had to go to the Developer options from the Settings in the Emulator,
then scrolled down a little, turned on the USB debugging. Instantly my device was recognized online, and I no longer faced that issue. I tried restarting android studio and emulator, killing adb process, but those did not work.
I also had the same issue. I've tried all solutions described here, but they didn't help me. Then I've removed all emulators in the Android Virtual Device Manager and created new ones. The problem was in the CPU/ABI system image configuration of the Android Virtual Device Manager. My Windows10 machine emulator with system image x86 is always offline, where the emulator with system image x86_64 is working fine as expected. Just be aware of this
I solved this by opening my commandprompt:
adb kill-server
adb devices
After starting up, ADB now detects the device/emulator.
In my case, I found some process that makes adb not work well.
You can try to kill some strange process and run "adb devices" to test.
It worked for me:
kill the process name MONyog.exe
Just write
adb -e reboot
and be happy with adb))
Enable USB Debugging into your emulator
Settings > About Phone > Build number > Tap it 7 times to become developer;
Settings > Developer Options > USB Debugging.
That's it enjoy
The "wipe user data" option finally solved my problem. just wipe user data every time you start the emulator. This always works for me!
I use windows 8 x64 , eclipse
open your emulator,
setting --> about emulated device --> click Build number repeatedly-->open developer options --> open USB debuggin
From AVD manager list at the actions dropdown:
Cold Boot Now
restarts it without all pain above.
Do you have bluestacks installed? If you do, the background processes that it runs creates the offline device "emulator-5554".
Go to the task manager and end all the processes with the description of "Bluestacks"
Try this ...
Close emulator if it Running.
Start Emulator again and wait for its online.
enter Command in commandprompt and press ENTER key : adb tcpip 5555
(Make sure that only One emulator running at a time.)
adb -s emulator-5555 emu kill
Press Enter Key....
Done.
check devices by command "adb devices" in cmd.
In my case, I started in 'Cold Boot Now' and clicked on Message to allow the connection.
Did you try deleting and recreating your AVD?
You can manually delete the AVD files by going to the directory they're stored in (in your user's /.android/avd subdirectory).
Go to windows task manager and end process "adb.exe". There might be more than 1 instances of the same process, make sure to end all of them.
on linux or mac the port thats blocked will emulator-id + 1 so 5555 so:
sudo lsof -i :5555
will show you the pid of process that are taking the port (should be the second column) so to kill it:
sudo lsof -i :5555 | awk '{print $2}' | xargs kill
then adb (fake) devices will no longer show on the list
In my case, the emulator was working with Oreo and lower, but not with Pie, and everything I tried seemed to have no effect. What finally worked was updating the emulator to latest (version 28).
I found that the emulation environment comes up as "offline" when the adb revision I am using was not recent. I properly updated my paths (and deleted the old adb version) and upon "adb kill-server", "adb devices", the emulation environment no longer came up as "offline".
I was immediately able to use "adb shell" after that point.
If the emulator is already open or executing it will tell you is offline. You can double check on the Command Line (Ubuntu) and execute:
adb devices
You must see your emulator offline, you have to close the running instance of the emulator (since the port will show as busy) and after that you can run your application. Hope this helps someone.
I tried everything but only this one works for my case:
Use SDK manager, and reinstall the system image.
Android Studio, click Configure, SDK Manager, Launch Standalone SDK Manager,
Check all "Google APIs Intel x86* System Image", "Intel x86 Atom*System Image" and install. Then re-start Android studio.
You might have to reconfigure and wipe the virtual device with AVD Manager, make sure you choose x86 version.
Ensure that your enable ADB integration is marked;
go to Tools>Android>Enable ADB integration .
if doesn't checked , check this option and close your virtual device and re-open it . this worked for me.. good luck!!
In MAC, you can use Activity Monitor utility, since, unlike Linux, we cannot use netstat -tulpn command in MAC. Search for the running instance of the emulator, typically qemu-system-i386. Kill that instance and you will see none of the ghost emulator running.
Simplest way to grab Activity monitor utility is to use spotlight search. just hit cmd-space and type in Activity Monitor.
I had the same issue with my virtual device. The problem is due to the Oreo image of the virtual devices that have the Play Store integrated. To solve this problem I installed a new device without the Play Store integrated and all it was fine.
Hope it helps, Bye
See emulator-5554 unauthorized for adb devices. On API 29 emulator I run adb devices command and got emulator-5554 unauthorized message. Then I created a new avd device from Google APIs image (in my case Q, x86), not from Google Play.
Simply delete and created gear avd again.It will work.

No logcat output in eclipse

I recently switched to connecting to the phone via WiFi. I am able to compile and upload programs through Eclipse. However, I do not receive any logcat ouput. The phone is also shown in the DDMS view and when my program is started it also displays the name and pid. Is it possible to get the logcat trace via wireless or do I have to switch back to using a USB connection?
UPDATE:
Maybe I did not make it clear enough in my initial post. There is no problem with the connection itself. I can dump the logcat by using a terminal with 'adb logcat -d'. What I want is to see the live logcat in Eclipse's logcat viewer. Not sure if it is of any importance, but I am using Eclipse 3.8 in Debian Jessie.
(1) connect phone with usb, then type in command line:
adb tcpip 5555
you can disconnect your phone from usb now
(if the reason for using wifi is that usb does not work on your machine, just do the above on another computer
(2) find out the IP address of your mobile device (somewhere under settings .... phone status)
(3) in command line type:
adb connect [IP of your mobile]
NOTE: all devices need to be connected to same wifi; avoid using public wifis
In your eclipse,
just go to: windows->preferences->Android->logcat and follow the following setup:
1. double-click action: "go to problem (error line)
2. switch to: java
3. both checkboxes are checked
if setup is fine, clean the project and restart eclipse
Restart Your ADB Server
1) open cmd
2) change directory to platform-tools
3)type adb kill-server
4)then adb start-server
I am not sure what exactly happened, but it is working now. I did not do anything that I had not tried earlier. It just started working after several attempts. Might be a faulty Eclipse installation, it did crash earlier today.

How do I view Log messages in Android?

I am trying to debug my android application using log messages. When I use System.out.println and Log.i and run the android application,I cannot see the debug message in either console or Logcat. If I have to get the debug messages do I have to run the android app in debug mode
from eclipse goto window -> open perspective -> other -> select DDMS.
And then run your app. And then select your running device from DDMS.
If it is not resolved your problem, restart your eclipse without closing your emulator and then flow the same above steps.
Njoy,
You do not need to run your app in debug mode to see log messages.
In order to see the log messages, you only need to have usb debugging enabled on your phone, the adb drivers for your device installed, and a copy of the android developer tools. It sounds like you have the above things, so I will suggest some steps for troubleshooting this.
Don't use System.out.println, because it does not allow you to specify a tag. Make sure that you set a good tag for your log messages. Once all of the above is confirmed, attempt to view the log message in eclipse's logcat view. Create a filter with the tag you are using because many messages will print and it may be difficult to find yours. You can also filter by application by using the name of your application's package.
If you have tried all this and you still can't see log messages, try running:
adb kill-server
and
adb start-server
If no luck, try restarting eclipse.
Confirm your device is plugged in!
If none of this is working, you can also run ddms from the sdk tools which is a bit more reliable.
Finally if that doesn't work, you can simply issue an adb logcat on the command line. If you have multiple devices, you can list them with adb devices and resolve the device or emulator with -d for the only connected device, -e for the emulator, or -s serialno to resolve otherwise.
There are also tools that will allow you to view the logs on your device, such as alogcat
sometime you may not select the emulator
and another way is to
restart your eclipse i also have faced this problem many times
If you're using Eclipse make sure that:
You have Debugging enabled in your device (or that you use emulator),
Your device is connected properly - it should show up in the Devices view. If you don't have this view get it from Window->Show View->Devices,
You've SELECTED your device in the Device View (simply click on it),
You don't have the LogCat paused and no filter is enabled - All messages (no filters).

Getting the error "device not found" when running a apk file from Android emulator

I am trying to install an apk file from command prompt but getting an error "Device not found".
try "adb devices" first and see the list of devices connected.
If the phone does not appear, do this :
"adb kill-server" wait a few seconds then "adb start-server"
If the phone appears in the list but its name is ?????, you have an issue of permission.
If the phone appears fine, you might have an issue in your command. Then check the following :
Is your phone in debugging mode?
Have you added the debuggable tag to the manifest of your application?
is the phone properly connected with the cable to your computer?
Have you done everything correctly on this page.
Fist turn on the emulator and then go to prompt and type:
adb install yourfile
Try adb devices
If you don't see your simulator device in the list although its on, you probably have to start the server. Execute adb start-server.
Then once the server is up again check for device by using adb devices command. Your device will be in the list
Now try to install the application. After installatio the application will be available in the menu.

Android Debugging with Logcat and Emulator. Is it possible?

This is pretty simple: I'm using NetBeans on Linux with Android emulator 1.6. I have Logcat on my android phone, but the process of getting the messages to somewhere readable isn't smooth at all.
Can someone tell me how to get Logcat running on the emulator? Is there anything I can do to see debug messages other then having to copy the apk to my phone and testing it?
Thanks in advance!
You have a few options for viewing the debug log output, assuming you have the SDK installed and your command path set up correctly:
Type adb logcat. The log output from the connected device or running emulator will appear. I usually prefer adb logcat -v time to see the time stamps.
Type ddms. This launches the stand-alone version of DDMS. It has a logcat display at the bottom.
Install the ADT extension for Eclipse, and open the logcat view. (Since you're using NetBeans I assume this isn't what you want to do, but I'm mentioning it for completeness.)
In all cases, the interaction is the same whether you're using a physical device or software emulator, because the ADB daemon conceals the details. Whatever you're doing for the device is also expected to work for the emulator.
If you have a device and emulator connected simultaneously, you can use adb -e logcat for the emulator and adb -d logcat for the device. From stand-alone DDMS or Eclipse, just pick the device or emulator from the pop-up menu.
If you have setup nbandroid you can find the adb logcat viewer in netbeans under:
Window -> Output -> ADB Log
--edit
Just followed up on the post above and started using C:\Program Files (x86)\Android\android-sdk-windows\tools\ddms which is alot better then the one in netbeans.
The SDK comes with a handy tool called ddms it should be in the tools folder of the SDK.
At the moment an Emulator is running, or a mobile phone is connected to your machine it should show up in ddms and you can see all the log output in ddms.

Categories

Resources