While debugging, Log.d() or Log.e() methods come to LogCat, but how do I capture the runtime error or trace log on the Android device when it is not connected to the development environment ?
Works only for rooted phones...They work by executing logcat utility and capturing the stdout (OutputStream). But to execute the logcat utility, you need root rights....
There are more utilities, but here's a sample from OpenIntents...
Logcat reader
It is not saved in your android device when adb is not connected to the developent environment, but you can save your runtime logs in a file
I have tried this and its working for me:: :)
To get the trace/issue logs user has to follow below steps:
1) First, user will be needing to DOWNLOAD AND INSTALL Google Android SDK program along with the Android USB drivers. User can download the Android SDK drivers from here :
"http://developer.android.com/sdk/index.html" ( To get started, download the appropriate package from the table above, then read the guide to Installing the SDK :
"http://developer.android.com/sdk/installing.html") and USB drivers for Windows operating system from here : "http://dl.google.com/android/android_usb_windows.zip".
Installed the Android SDK to PC if not available.
2) Connect the Android device to the PC using USB.
3) Open the Command Prompt ( Terminal on MAC ) and go to the SDK/tools path on prompt (e.g. xyz-Devlop:tools username$, on my mac machine), then execute the
"./adb logcat" on MAC and "adb logcat" on Windows, command on Command Prompt (e.g. xyz-Devlop:tools username$ ./adb logcat, on my mac machine).
4) Run the application on device.
Logs will be then available in the Command Prompt/Terminal.
Enjoy Coding/Debugging...... :)
Related
unable to connect to adb.check the event log for a possible issue, verify that localhost entry is pointing to 127.0.0.1 or:: 1 for ipv4 or ipv6.
Getting an error while running my sample application in android device.
ADB error on a fresh installation of android studio.
Finally I got answer for my own question. This is due to some Windows OS update issue. Please follow the below step to confirm.
Goto C:\Users\bn\AppData\Local\Android\Sdk\platform-tools
Open command prompt from this location and type, adb devices
If you get below error dialog, then the problem is with your windows setup and not any issues with Android Studio.
adb command error
Solution:
Download the package for your Windows version from below link. In my case I have downloaded "All supported x64-based versions of Windows 8.1" package and installed the exe. Once installation is complete check the adb command. It should work.
https://support.microsoft.com/en-us/help/2999226/update-for-universal-c-runtime-in-windows
I get following error when I run react-native run-android in CMD(windows command prompt)
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html
What caused This problem?
Thanks in Advance.
check your device connected or not by execute below command in cmd
adb devices
if adb not found then open below dir
C:\Users\MANGO\AppData\Local\Android\sdk\platform-tools
then check device connected or not
then you can lunch your app
i hope it solve your problem
Set the sdk platform tools path in system variable inside Enviroment variable.
With this you can check the connected devices from command promt.
Note: Make sure you have connected your device to PC with USB debugging On from developer menu. You can follow this link
Then follow following steps.
From command prompt type " adb devices ", if you are connecting the real android device first time then inside your device there will be a RSA key generated which you have to click "OK".
Then to confirm from devices you can again type adb devices if all went good it will show your device.
Move to your project folder from command prompt and then run your app from command prompt.
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.
My Phonegap app refuses to load onto my Android device (even the HellowWorld default app is refusing to load)
Everything was running just great until today.
Here's my console log:
***\>adb devices
List of devices attached
4c05609b device
***\>phonegap run --device -V android
[phonegap] detecting Android SDK environment...
[phonegap] using the local environment
[phonegap] compiling Android...
[phonegap] Generating config.xml from defaults for platform "android"
[phonegap] Compiling app on platform "android" via command "cmd" /c ***\platforms\android\cordova\build
[phonegap] Platform "android" compiled successfully.
[phonegap] successfully compiled Android app
[phonegap] installing app onto device
[phonegap] Generating config.xml from defaults for platform "android"
[phonegap] Running app on platform "android" via command "cmd" /c ***\platforms\android\cordova\run --device
It just sits there saying running... forever.
I have another terminal window open with adb logcat running and at some point (maybe 10-15 seconds into that last line getting printed) it stops logging. Termination of the process and subsequent calls to adb logcat result in more hanging (no logging at all)
So then I have to do a kill-server, start-server to break out of this endless hanging at which point the phonegap process terminates with:
[error] An error occurred while running the android project.
***\platforms\android\cordova\node_modules\q\q.js:126
throw e;
^
ERROR: Failed to launch application on device: ERROR: Failed to install apk to d
evice: Error executing "adb -s 4c05609b install -r "***\platforms\android\bin\Po
ached-debug-unaligned.apk"": protocol failure
I have tried::
deleting my .cordova folder in C:\Users\Name
running the adb install directly (without phonegap)
deploying to an emulator (same problem)
unplugging / replugging the device
rebooting all devices
toggling "developer mode" on the device and revoking USB debugging privileges
I am all out of ideas!
Would greatly appreciate any tips or leads.
ADB version 1.0.31
Galaxy S3 running Android v4.3
EDIT:
Deploying to an emulator claims to complete successfully, but the app never opens and does not appear in the app list inside the emulator. So I have no way of actually testing it on the emulator either.
Would really appreciate some assistance.
EDIT 2:
After some further tinkering I've discovered my issue can be more specifically described as ADB hangs (freezes) when I attempt to talk to my device. I've determined this because adb shell, adb install, and adb push all fail the same way as described above. No error, just finite waiting.
adb logcat, adb devices, and other read functions work perfectly fine until one of the aforementioned write functions hangs in which case I need to do a adb kill-server or TASKKILL to get adb logcat working again.
Not sure if this added information helps, but there you go. The last thing I haven't yet tried is to do a factory reset on my phone as suggested by this fellow. If I can't find a solution soon I will back up my data as best I can and attempt this...
Please save me before this becomes my last option!
In case this helps others I had a problem with similar symptoms. ADB install -r "apk path" would hang indefinitely.
I troubleshooted a myriad of things and identified that it was my USB cable length.
I have an USB extender cable as that I plug my devices into. The combined length of my device's cable and the USB extender cable caused this issue. Removing the extension cable fix the issue and eventually I replaced my USB extender cable with a shorter extension cable for the final solution.
The issues seems to resolve itself randomly. As others suggested, an arbitrary combination of ADB kill-server, restarting the device, and re-installing SDKs seems to alleviate the problem (even if only for a couple pushes).
I still have no idea what causes this hanging and, though superstitiously believe the arbitrary combination described above fixes it, am unsure how to permanently resolve it.
To future people reading this, until a solid explanation is given my only advice is to square away an hour or so to restart / rebuild your dev environment... and make sure you buy a durable stress ball.
Shot in the dark here, but some more things to try:
Are you on a work PC or something? Make sure you have USB write permissions. Also, try different USB ports and cables. You have the latest USB driver for your devices right?
Try updating the SDK tools. Or maybe something got corrupted and a re-install might do the trick.
You have free space on your devices right?
Unknown sources is checked on both devices?
What version of Android are you targeting?
Do try restart the device like other suggested. From my experience, kill the adb process, then run the cordova run command helps magically sometimes.
In my case adb seemed to hang, but in fact the data transfer from Mac to emulator was really slow:
$ adb push platforms/android/build/outputs/apk/android-debug.apk /data/local/tmp/
150 KB/s (15587200 bytes in 101.223s)
It's a lot faster on USB connected real device. Don't know why...
Had the same (original) issue (with cordova / testing on an old device) ie. hang during install.
Tried running adb install directly from cmd line ...
adb [-s <deviceID>] install <apk>
...and same issue so not cordova specific....
Opened android device monitor (ADM) ...
..sdk\tools>monitor
..and ran install from cmd line again and saw logcat message saying package was sdk 16 / device was 15...doh!
So went back to AndroidManifest.xml and changed android:minSdkVersion to 15 and all back to normal again - install worked fine.
( Issue arose because I had installed something else which had changed the minSdkVersion and then removed the something else and never reset the minSdkVersion )
So, possibly device sdk / android version is too low for your build. If not, a look at the ADM logcat output as you initiate the install from the command line might indicate what the issue is.
Unplugging and plugging device again usually helps.
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.