Testing an android app for restart functionality - android

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.

Related

How to view logs even if the app has been disconnected in Flutter?

I need to see the logs when the app is closed (removed from memory). But doing so disconnects the app and therefore I can't see print statements in IntelliJ console. I thought adb logcat would still show the logs, but it stops logging upon disconnect too. Can I achieve what I want without using background services?
Connect your device to your machine and run flutter logs

Google Nearby not working on Android Things by default

I'm developing an Android Things application on the iMX7D development board and I have implemented Google's Nearby services. The issue I have is that I get an error (sometimes) when I begin advertising the device. Here is the error:
com.google.android.gms.common.api.ApiException: 17: API: Nearby.CONNECTIONS_API is not available on this device.
I have managed to fix the error by following the instructions on https://stackoverflow.com/a/51428433/6377151, and that allows the code to run fine. The error gets fixed if I run the ADB command
adb shell am force-stop com.android.iotlauncher.ota
And then run the application, but that only works for the one time. As soon as the device is rebooted, the issue comes back. I'm aware that this is because the default launcher is already advertising the device, but I'm not sure how to fix this issue in code automatically when my application runs. But I need a way to either do this automatically on startup or to overcome the error in another way.
My Android Things device is running Android Things 1.0.10. Can anyone assist?
Disclaimer: I work on Nearby.
We have a release ready to allow multiple apps to advertise/scan at the same time. It's code-complete, but code pushes are slow at Google. It'll be a while before it's public. Note: Android Things boards might need to be reflashed to get the update. That was the case in development, but is hopefully not the case for release builds.
In the meantime, you'll unfortunately have to either install another launcher, or force stop the existing one. We treat clients as first-come-first-serve.

How does Android device monitor enable inspection/dump of webviews?

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?

Android: understanding reasons of device crash

The device I use for development process self-restarts once in a while. It happens when it is not in use - just lying quietly on the table not even connected to a computer.
I'm worried that this may (or may not - I don't know) be connected to my app problems.
Question: How can I get info on crash reasons after device restart? (Logcat can't get anything after restart).Thanks
Try to log to a file or rest web service.

Retrieve adb logcat files from a client's device

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.

Categories

Resources