I'm trying to understand why I get a correct hierarchy dump of a webview after I start the Android device monitor (SDK/tools/monitor.bat) but not before. It's enough to simply start it once, after that I can close it and it still work every time (until I reboot the device). So it must send some kind of command or do something.
This is the command I use:
adb shell uiautomator dump
Before I open Android device monitor:
After I open Android device monitor:
As you can see in the second image I can now see all the different nodes inside the webview.
I tried to look through the console output to see if it send some kind of command to the device but I'm not really sure what I should look for. Anyone have an idea on what it can be?
Related
I would like to be able to type commands on my development machine (macOS/zsh) and have them do things on my Android app. This will require custom code in my Android app. What I'm trying to do is something similar to automating certain settings, so that I don't have to navigate to the settings screen of my Android app manually. This is to help me save time while I'm developing my app.
How can I get started? I'd love to see some examples of this being done but have been having trouble finding them.
Are there any libraries that can help me with this?
Also, for bonus points, I'd love to be able to have some sort of autocomplete on my Mac command line. How might I build that?
There's a few ways to do this:
1)Just write a Linux app, move it to your device, set the executable bit, and run it from adb shell (adb shell opens up a shell on an attached device with debugging enabled).
2)If you really need to access the app while its running, you can send intents to your app via the shell via adb shell am <options> This allows you to send an intent to the system. Then just write a custom Activity, Service, or BroadcastReceiver to receive that Intent and act upon it.
I want to be able to access logcat for an app running on an Android TV device, but the TV only has a USB plug not micro-USB.
The Android TV device is
Running a custom Android 4.2.1 ROM (from manufacturer)
Doesn't provide access to device settings
Only has USB plugs
Environment#getStorageState() is always MEDIA_REMOVED
How can I get access to the application log?
You refer to
access logcat for an app
If "an app" is one that you are developing, then although Android now restricts installed apps from seeing the global logcat output, it still allows you to access data that your own process sends to logcat (whether from your own code, or from framework code that runs within your process). It's a simple matter of getting your app to run the logcat command on the device to send the data to a file, and then uploading that file to a webserver somewhere so you can read it.
(Read logcat programmatically within application gives the general principle, which is to exec the logcat program, and then read its output).
If however you are trying to get the logcat output from all the apps on the device, then getting adb working in some form is your only viable choice.
I assume you can install apps on the device, by placing them on an external website and downloading them using the device's webbrowser, then opening the downloaded file.
Thus you may be able to install a settings app extracted from a 4.2 phone, which might allow you to turn on adb debugging (though as you point out, the physical cabling is unusual).
For those facing a similar issue, the solution I have chosen is as follows:
Created a replacement for Android log that decorates Android log but also logs to a log4j RollingFileAppender. This was necessary because the circular logcat buffer on some of the devices was so small that it only contains 5 minutes of log.
Added a menu action that posted all the log4j log files to a web
server
Added a Servlet to my web server to capture client log files and
write them somewhere meaningful.
This seems to work reasonably well.
Aside from item 1 it is pretty the same as zmarties suggestion.
I am trying to develop an Android App that, though having an Activity, needs to run in the background as a service. The app needs to start up automatically after rebooting the phone/device.
My question is HOW to troubleshoot such requirements, since the LogCat gets disconnected when the phone is rebooted, even using "adb shell broadcast -am android.intent.action.BOOT_COMPLETED" on a connected phone. (Though possible on an emulator, I dont feel like it is able to properly replicate real-world scenarios). I would like to be able to see the Logcat messages after device restarts, thus allowing me to troubleshoot ANRs and app crashes during reboot.
Any pointers would be appreciated.
Based on this link, I understand the closest we can get to debugging reboot errors is to use
adb logcat -v time > <localfile>
or
adb bugreport
Both of these options may not be the cleanest ways to pinpoint the issue, but atleast something is better than nothing.
I'm making an app for a client, and they are experiencing bugs that no one else can reproduce. They are not close to us, so I can't physically go to them and hook their device up to my laptop.
Is there a way that they can get hold of their logcat files without having to install adb on a machine first, i.e. can they email them straight from their device? I'm not sure how tech-savvy they are, and ideally I don't want to spend too much time telling them how to install adb if I can get the files some other way.
Obviously I'm looking to do it with their permission (and I'm expecting that installing adb is going to be the only way).
Edit: I should add that I'm using Corona SDK, so will not be able to access the logs from directly inside the app. Also, all devices are 4.1+ so the various log collector apps have not worked.
You can redirect the logcat to a file and send it by email using your app.
Check here how to save the logcat into a file.
At this moment, this error started with IDEA 11. I still did not find the right pattern but if a device or emulator are idle for a specific period of time (not long) and if I then try to push the project to a device/emulator and to attach a debugger, first appears a message that IDEA is trying to connect to ADB (a several message windows) and then the upload starts, the apps gets uploaded, then it fails with error:
Launching application: com.xxx/com.xxx.sMain.
DEVICE SHELL COMMAND: am start -D -n "com.xxx/com.xxx.Main"
I/O Error: Connection refused
The only solution is to close both emulator and IDEA or to disconnect a real device from USB cable.
Any ideas why this is happening? As I said it happened with both device and emulator so I cannot tell that it's up to a device/emulator.
EDIT
I tried restarting ADB via shell, it did not help either. This does not happen when I simply run the project, but only when I press debug.
EDIT 2 (18May)
I've noticed that this is happening when two IDEA's screens are opened in the same time. For example, I open another project and choose to open it in new window. I first run the app in window 1, and then in window 2, but then the popup "Trying to attach to ADB" keeps opening and closing. I see that memory increases for a couple of MB as each time a new popup is created. this leads to IDEA stop responding and I have to kill it.
I think this is a new bug.