How do I view Log messages in Android? - 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).

Related

Android device is not responding

I used Unity 2019.
When I connect my android devices (3 devices, tablet included) to Unity and try to run and build any apk, devices are recongized in Unity but the compilation process fails. lt's, writtren :Android device 52000... is not responding
I had this problem with my new phone, which was occurring even after enabling USB debugging and authorizing the PC through the phone. I ended up finding the answer in here Unity's documentation:
Run the adb devices command from the platform-tools directory of your
Android SDK installation and check the output.
If the output list is empty and you are using Windows, you may need to
install the driver for ADB devices. For more details, refer to the
Android SDK/NDK Setup documentation.
If the list contains entries with the unauthorized label, you may need
to authorize your computer on your device and give it permission to
debug it. Check the device’s screen for the corresponding dialog.
If the list contains your device with the device label, build your
Project in Unity again.
I resolve the problem.
In USB connection mode, on my phone, there are 4 options:
Transfer files
transfer images
Connect a MIDI device
Charge this phone.
I ONLY changed the connection mode to TRANSFER IMAGES.
After that, I received a prompt asking me the validate this connection mode. I did it and it works fine.
I resolved this issue, by changing the USB connection mode to Image Transfer(PTP) in my MI device
the problem is very clear. The compilation is successful, which means there is nothing wrong with your code. And the error message in the dialog box is clearly saying that
Make sure USB debugging has been enabled
So, to solve this simply follow the steps below -
Navigate to Settings > About Phone > Scroll to bottom > Tap Build number several times
Go back and now access the Developer options menu, check 'USB debugging' and click 'OK' on the prompt
You can also checkout this link
On android device, when prompted for "Allow USB debugging?", selecting "Always allow from this computer" checkbox solved the problem for me.
In order for my phone to show up the "Allow USB debugging?" dialog, I revoked the USB debugging authorisations from my android device and then ran "adb devices".
Also once I did this, unity was showing my device name instead of just device id.
Here's what worked for me.
Windows key type cmd
cd C:\Users\[name]\AppData\Local\Android\Sdk\platform-tools
adb kill-server
adb start-server

Eclipse - Empty Logcat with Android 7

I recently updated my Nexus 9 Tablet to Android 7 Nougat.
Since then the Logcat view in Eclipse stoped displaying Logcat messages, the view just stays empty.
Also the devices target is shown as "Unknown".
If I instead start Logcat outside Eclipse (AndroidSDK->tools->ddms) it displays all messages. However, then the "Application" Column stays empty.
There are allready some (older) questions on this topic here on SO, but none of the solutions here worked for me.
What i tryed:
Use another USB Port
Focus the device in the DDMS perspective
Restart Eclipse
Reboot the device + pc
abd kill-server
disable and re-enabled USB Debuging on the device
Reset the USB-Debuging authorization and confirm the RSA fingerprint again
Switch USB-Mode to "MTP"
Every installed package from the Android SDK is up to date and i use latest Eclipse+ADT Plugin.
Also everything works fine with my Galaxy S5 Mini (Android 5.1.1).
I know, that the ADT-Plugin is deprecated and we should use Android Studio.
However I still preffer to use Eclipse as long as possible, so I am looking for a solution for this problem.
So does anyone know how to solve this issue?
I tried with this custom build and it works for me. Now I can see my logcat in Eclipse again.
https://github.com/khaledev/ADT/releases
Download the zip file then in Eclipse menu Help > Install New Software... > Add > Archive...
Just pick the downloaded zip and do the rest of the install process.
can use "Android Device Monitor" Application,
This application in the sdk-tools package.
Launch From the command line,
cd to the "sdk-tools folder/tools/" directory,
enter the following command : monitor.
or
windows environment,
open the directory "sdk-tools folder/tools/",
and double click monitor.bat.
detail -> Google User Guide
I had the same problem. Eventually, I found out that the "Eclipse IDE for Android Developers" was out of date. Updating this feature fixed the problem. Procedure:
Open Help -> About Eclipse -> Installation Details
Select "Installed Software" tab
Select "Eclipse IDE for Android Developers"
Click "Update" in the bottom.
Try to launch directly sdk tool monitor from Android SDK, it can be found in:
sdk-tools folder/tools/
you'll see monitor.bat, click on it to launch Android Device Monitor oustside Eclipse, don't forget to create a filter for your APP, go to logcat window-> Saved filters -> + -> fill your app name in "by Aplication Name"
If nothing works, in an emergency, you may try this to get logcat over command line (use cmd in windows), type :
adb logcat --pid=YOUR_APP_PID_NUMER
this shows messages from your APP. if you don't know your PID, put a line in your APP code:
System.out.println("foo stuff I can find easily when I read logcat results");
Run your app, make sure you get the up line executed.
Then in your command line type:
adb -d logcat System.out:I *:S
Find your line System.out.println("foo... and read the PID number, is next right to time data.
And then
adb logcat --pid=pid number you read from your comment line
to get logcat messages from your app in the command shell in real-time.
If you just want messages output till now, just add -d modifier:
adb -d logcat --pid=pid number you read from your comment line

How to debug signed Android app from Eclipse?

Android 2.2.
I need to debug my signed APK on my Nexus S. How can this be done using Eclipse?
I start the app on my phone and then...?
Set the debuggable=true in the manifest, export, install and sign the the app. Connect the device via USB, enable USB debugging. Then open the DDMS perspective, select the device and attach to your app's process (you will see the package name listed). If you have a rooted device, you can connect to any process if adb is running as root.
When device connect to your eclipse running mechine , set debuggable=true in manifest file and enable debug mode in android phone it can view current running log using logcat, otherwise
You can debug your running application using adb tools from the command line
adb logcat - View device log
will display the current logcat (debug messages)
adb logcat [ <filter-spec> ]
using you can filter only your given debug messages
for configure debug tool view
http://developer.android.com/guide/developing/tools/adb.html
In Android Studio stable, you have to add the following 2 lines to application in the AndroidManifest file:
android:debuggable="true"
tools:ignore="HardcodedDebugMode"
The first one will enable debugging of signed APK, and the second one will prevent compile-time error.
After this, you can attach to the process via "Attach debugger to Android process" button.
You have two ways ..
You can use Log.v or log.d or Log.i (Logging) in your code and get all those logs in logcat view in eclipse while your application runs on your device.
You can run (while debugging , pressing that insect icon on eclipse ) the application from eclipse on device, By putting breakpoints in your code you can debug your application.

Android: Logging on an android device

I am no good with hardware concepts. So I have this probably very silly doubt.
I want to add Log to my application. When running on an emulator, I know where to see the Log output - it's visible in the Logcat window of Eclipse.
I want to know where I can see these logs when I run it on a hardware device. I am using following command to load my app on to the device : ./adb install helloWorld.apk
So where will the log be created and under what name?
Apologies if the question is vague or silly. I really do not know more details.
-Kiki
Try to use:
./adb logcat
When you run on device, the log is also available in LogCat. You will need to turn on USB debugging (Settings > Applications > Development > USB Debugging) in your device, then you can use LogCat just like in the emulator, both using ./adb logcat and in Eclipse.

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