Custom apps wont turn on after reboot - android

I have written some basic apps for both iOS (using Swift) and android (using Xamarin). I am often bugged by a problem on both platforms: When I try to run my app from the device (that my IDE installed for me on the device) after a while, it just wont turn on (usually crashes without an error message within the first second of loading). Everything is always fine upon recompiling. With android, this happens usually whenever I haven't recompiled since last reboot. With iOS, it seems pretty independent on reboots, but usually happens within hours, sometimes days.
Why is that? Is there any way to prevent this (Preferably one that wouldn't drastically increase installing time, like posting my app on store or at least creating an installation package and installing it manually)?

Related

Android: is there a way to dump crash logs locally on test device with no computer connected

I'm experiencing pesky SIGSEGV faults in my Android app. They are inconsistent to reproduce and mostly happen after my app has been restarted a couple of times. The problem is, when the app restarts, Android Studio stops showing the logs, making it very hard for me to figure out what the issue is. When I restart the app using the Android Studio restart button, it loads a fresh install of the app onto my phone, which is an issue because the errors don't seem to happen on very fresh installs.
My question is: can I somehow have Android Studio still show the live logs WITHOUT reinstalling the app every time, OR can I run the app without being connected to any PC, and dump a crash log file locally to the phone when the app crashes, so that I can open the logs later on?
Filtering logcat
The problem is, when the app restarts, Android Studio stops showing the logs, making it very hard for me to figure out what the issue is.
It sounds like the logcat in android studio is filtering by application. You can change it to no filter and set the text filter to your application's id. This way the logcat will not be cleared once the application process dies/restarts.
Extracting the tombstones
Since this is an Android native crash it will not be sent to bug capturing software such as Crashlytics or Bugfender etc.. you can pull the tombstone[s] directly from the device with adb.
adb bugreport bugreport.zip
Once extracted, the tombstones will be under path /bugreport/FS/data/tombstones/.
Typically 10 tombstones will get saved to device storage but will get overwritten by earlier native crashes once the limit to the number of retained tombstones has been met.
Android documentation: Using bugreport
Android documentation: Debugging tombstones

Is Android Studio Emulator supposed to be very buggy and glitchy?

I am currently developing an Android app without an Android device.
Therefore, unwillingly, I am using Android Studio's emulator as my only source of testing.
However, half the time I use the emulator, the program glitches and the app either stops or does not trigger the functionalities that I put in.
However, the other half of the time (I did not change any line of code when doing this), I'll simply run the emulator again and the app will function normally.
But now I am concerned about this because I am not certain if this is only a bug in the emulator or if the same thing will happen in a real device. Since I do not have an android device, there's no way for me to text this in a real setting.
Can I just ignore this glitch? or is this actually an issue?

Android app appears in Battery Optimizations whitelist, but is not actually there

Background:
I am developing an Android app. When the app starts up, it checks to see if it is excluded from Battery Optimizations using the isIgnoringBatteryOptimizations() function. If that function returns false, I use the REQUEST_IGNORE_BATTERY_OPTIMIZATIONS permission to show the Battery Optimizations Settings screen, where the user is expected to add the app to the whitelist.
This all works perfectly when I run the app from Android Studio. The trouble starts when I download and install the release candidates.
Note that the issue I will describe only happens on one of my two phones. The issue happens on a Sharp 507SH running Android 7.0. The issue does not happen on a Sony SOV32 also running Android 7.0.
The issue:
When I download and install the release candidates (not using Android Studio) and start the app, the Battery Optimizations screen is shown as normal. However, the app appears already listed in the "not optimized" whitelist right away. Normally the user has to manually select the app and add it. But it appears in the list. So the user presses the back button to return to the app and everything seems fine. However, the app is not actually in the whitelist. This is confirmed by the fact that the app prompts the user every time the app starts, i.e. isIgnoringBatteryOptimizations() is still returning false.
I can add the app to the whitelist "for real" by first going in to Battery Settings and removing it from the whitelist, then adding it back. Then the prompts disappear as they should.
I am late to the conversation, but I have experienced something similar to what paperduck said above.
I cannot 100% prove it, but my experience shows that when testing on an emulator and my own device (Huawei P20 Lite), with the application installed via Android Studio, the application says that it is on the Optimisation list. Adding or removing the application from the Optimisation list does not change the returned value.
This may be a side-effect (bug) of previously installing the APK on the phone outside of Google Play. We are downloading and installing APK file release candidates directly from Google Drive. The phone which had a previous APK file installed experiences this problem. The phone which has not had the APK file installed directly before is not experiencing the problem.
We haven't confirmed this. It is our suspicion.

Android emulator stops responding after one interaction

So I'm using an Android emulator (the stock one) to test out my react native application I'm building.
I can load my app on the emulator using react-native run-android and then my app loads fine. However I can only ever do pretty much one interaction, such as pressing a link, after that my app just doesn't respond and I have to restart my react packager to get it to reload. Are there any reasons why this might be happening and how this can be resolved please, it's making it super hard to develop any project.
There is no strenuous code in place and runs fine on my IOS emulator.
I've been having similar issues, especially after rebooting the emulator. I've found that the best solution is to reset the emulator and check the wipe user data box. You then need to wait until the emulator is fully booted before starting the packager. This works for me most of the time in 0.14, but isn't foolproof. I would also check the chrome debugger and make sure there aren't any IOS exclusive parts of the code causing issues, but I'm guessing you've tried that already.

Reasons why my Android App would crash on my phone consistently, but not on my emulator

I have an app that uses quite a few graphics in it.
When I open and close my app repeatedly on my emulator (1.5 - 2.2) it runs fine and by checking the heap I can see everything is being cleaned and gc'd properly.
However, when I run my app on an HTC Aria phone (2.1) the app crashes every time I try to re-open it. When I look at the heap I can see that objects are NOT being cleaned up like they are in the emulator.
Does anyone know why this behavior could be happening? I did try it on another HTC Aria (a friends) and it crashed the same way as on my phone so I think it's not just isolated to my particular phone.
Any thoughts or ideas would be really appreciated on why things are cleaning up properly on the emulator, but not on my phone. One thing to note, is that I DID have it working and gc'ing fine on my phone a few days ago and I didn't change much and now it's not working on my phone so it's a bit of a mystery to me.
Thanks!
Note:
The crash is caused by an OutOfMemory Exception. I'm pre-loading a handful of graphics, and there's not enough memory for two instances of the application to be running at the same time so it's crashing because the 1st instance of the application was not cleaned up properly.
You have several emulators, all running just this app, closing it and start it again.
Your Android device has several processes running the same time, like background sync, Facebook notification, Twitter notification, Calendar sync, Contacts sync and the like.
One way to look at this is to try to mimic your Android device state on your different emulators, and see if you can get the same error on the emulators. Use some apps that sync in the background and others who use a lot of memory. Then you have a testing environment that mimics the real world, and you can change your app up to a state where it doesn't crash. Maybe downsize the images as much as you can to ease memory usage.
Remember, you can never force the Garbace Collector to start. You can only tell the system that it is possible to collect this garbage.

Categories

Resources