New at Android. I am testing my app via Android Studio, running, not debugging. My device is a Samsung S2, API level 16.
Almost every exception freezes the device and requires restart or even battery remove&insert. Any solution to this?
UPDATE:
This seems not to be code related and happens on different projects. Any NullPointerException for instance would cause the device's screen to turn black. Sometimes the device will restart itself, other times I would have to remove the battery and re-insert it.
Related
Recently my Android TV app has started to restart itself about every an hour. The min SDK version is 27 and the tv is Sony Bravia.
So when the exoplayer (r2.15.0) in my app is playing HLS in full screen, the app might throw users back to the main screen of my app. The main screen is a few Activities away from the video screen.
I have tried adb but every time this happens, the Android studio only shows the adb disconnects. There hasn’t been any logs that I can look at.
But if I just let the app run videos in the emulator on my computer, it is fine.
Any people have any ideas?
Usually due to memory issues (memory leaks eating up all the memory). Another would be a setting where you can set it so the OS closes background apps and reopens them when being active.
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?
I am new to Android Studio (running the latest updated version) however I am trying to debug with Android monitor and Logcat only seems to work once then stops reporting!!!
This occurs for all my projects?!?
If i restart Logcat it just clears the messages.
I assume the emulator cannot connect to the debugger for some reason.
When I restart Android Studio logcat reports, but when I close the app running on the emulator it stops reporting.
This CANNOT be the default intentional behaviour, does this affect other people?
Many thanks for any help at all.
Simply restarting Android Studio is the best solution
By default if your close the emulator it unattaches itself from Android Studio, stops Android Monitor and logcat and doesn't reattach when starting again. If you stop it in android studio and run it again the emulator is still attached to Android monitor and logcat.
I assume the emulator cannot connect to the debugger for some reason. When I restart Android Studio logcat reports, but when I close the app running on the emulator it stops reporting. This CANNOT be the default intentional behaviour, does this affect other people? Many thanks for any help at all.
An answer to this part is that it does not sound like expected behavior of Android Studio / logcat / emulator. I am able to start and quit the app multiple times, each time logcat connects when the app begins and disconnects after. I can start the application through Android Studio or through the apps menu on the emulator. I can quit and restart the emulator.
An easy thing is double check the dropdowns along the top of the logcat display, especially the emulator, app, and filter selectors.
I once had an issue that sounded similar, with logcat not reconnecting. The issue there was my terminal and IDE were running different ADK installs and they were competing for the logcat connection. So what you describe is possible, but not the norm. Perhaps another debuggable app or connected device could cause similar confusion.
I have written an app and on some devices, using the app freezes the system. My main problem is, that I do not get any log information, because as soon as the device is frozen, logging completely stops and obviously the crash-reports normally would be generated after the crash, which does not work, because the device is frozen.
I have attached the device to my laptop via adb (via USB) and logcat everything, but the logging just stops as the device freezes. I have also checked all possible log locations (I used this reference) and could not find anything.
Since the app crashes only on about 10% of all devices (the devices are identical and have the same firmware) I need to test the app on the device and cannot use the emulator. However if the app crashes, I can relieable reproduce the crash using adb monkey. On the other 90% adb monkey won't crash the device.
Is there anything else I can log / test / check? Is there a way to get a memory dump, once the device is frozen?
Although I don't think this is relevant: The device is a XORO 9718DR tablet and the device is rooted. The app is written by myself and not available in the market. It mainly uses only Buttons, TextView, ImageView, HttpClientConnection, Threads, AsyncTasks and other "normal" Android stuff. It even does not use the webview.
Use DDMS to trace heap memory here.
In your manifest file put debuggable=true. Build your app and install it on your device, run DDMS. Select your app from the list, and enable Heap from the toolbar button.
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.