My application is probably running out of memory or it is some issue with that. I have exception handling on application so if i got exception It is send to my email, it is good for debug, but recently I have got a strange issue, when I put my application to background and start 2-3 other application for example Gallery when i want to reopen my application instance it shows me Application stops work and no exception is send to me, so it is hard to solve, can you please help me to solve my issue, or handle that memory issue and restart the whole app instead of showing that the application has stopped worked.
thank you very much. It will also help if you show me how to simulate that memory issue when the application is in debug mode.
my manifest:
<application
android:name=".utils.JLApplication"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="JustLook"
android:largeHeap="true"
android:noHistory="true"
android:launchMode = "singleTop"
android:theme="#style/JLTheme">
I also think that maybe my application is correct but some of the libraries or something has stopped to work and that throws my application. But I am not sure of that. I also noticed that it happened frequently when i implemented google api connection and fuse location listener, but i am also not sure if it causes this kind of problem, maybe the memory issue is more likely bug here. But I dont know how to find it or solve it because it does not throws exception.
I dont think that your problem is memory related.
According to how you describe your problem, i'm assuming that your crash is caused by a NullPointerException.
As MarkySmarky described, Android kills background applikations to gather memory space.
So please have a look at your MainActivitys onResume or onStart. There must be some handlers, adapters, etc. that are null when you are resuming your app.
In addition, i would suggest to add Crashlytics to your project. It tracks your crashes in detail. If have a crash report regarding your problem, please post it here.
I must say that the behaviour that you've described sounds perfectly normal besides that crash thing ;)
Android kills background applications when it needs to free up memory for other apps. The crash you're having MUST somehow be related to your code running in onCreate() of JLApplication. The best way to debug or find this bug is either start your application in debug mode or spread logs all around.
You can also take a look at Debug.waitForDebugger().
btw you should have a really good reason for having the following in you application tag - "largeHeap"
Related
I'm having a problem where an app I'm developing is working on mobile devices (tested on 4 different devices), but crashing when I try to test it on my tablet. The tablet I'm using is a Tesco Hudl 2, which, although being a good quality low cost device, lacks adb drivers and so you can't debug apps through USB and get the Logcat data. The app was developed using Android Studio.
With other apps I have developed, I have just set up ACRA in the project so I can still get debug information from a crash. This time however, the app is crashing without any information from ACRA and so I'm not quite sure what is going wrong. I'm pretty sure I've set up ACRA correctly given that I've used it in several projects before and see nothing wrong this time. Can it be that whatever is going wrong is happening too early for ACRA to catch?
I have pulled out all the code from the activity so the only thing that happens in code is that ACRA gets initialized in the derived Application class (note that the crash exists without ACRA). The app also uses Google maps and a provider for search suggestions. If there is any code anyone wants to see just ask, but I'm unsure what exactly to post up since everything else was stripped out. So, does anyone have any idea on what I can do to solve this, or what tools I can use to catch whatever sort of errors happen so early in the apps lifecycle?
Thanks
Update with strange behaviour... Downloaded Crashlytics and it also did not catch the crash. I copied the project and removed every .java file except the Application, Activity and provider. The provider functions were empty (save for the return value of 0/false/null/whatever), the application class just initialized Crashlyitcs and the Activity class was empty. This then worked, I was even able to add in a lot of the code and get the google map to load.
Now if I do the same in my main project, except don't delete the .java files, the crash still happens. The classes in these files are not used so I have no idea how they can be causing the crash. Otherwise all the xml, gradle, resources are identical (except the package and app name). Very confusing...
Consider using one of the apps to view logcat on the device:
https://play.google.com/store/apps/details?id=com.nolanlawson.logcat
https://play.google.com/store/apps/details?id=org.jtb.alogcat
Also try using Crashlytics. Maybe it will catch your crash?
But yeah, it's possible to have a crash before any crash reporter (ACRA or Crashlytics) will have a chance to catch it.
And one more note, maybe there is a way to enabled ADB over WiFi.
Normally you would need to enable it via adb but maybe in case of this cheap and strange tablet, there is an option for that enabled in the ROM?
Ok! So it's 1am and I decided to have one final attempt to fix, which I think I did. In my manifest, I had things like
<activity
android:name=".MyActivity"
...
for example, and while this worked fine on the mobiles, for some reason the Hudl required the complete package name, i.e. com.mypackage.MyActivity. Not sure why this is the case but it appears to have fixed the problem.
I'm developing an app using Android Studio. Now I'm facing a bug where the app crashes when I do the following:
Press the home button.
Use the device for some 10 minutes (i.e. wait).
Run the app again. Crash!
There is no easier way to reproduce the crash (nothing in onResume). As you can imagine, this is kind of hard to debug. In an ideal world, the OS (Android 5.0) would let me send a bug report to myself. The app is not published yet, so I don't see how I could get hold of the crash dump. Is it saved somewhere on the device?
I did try to debug the app from Developer Options, using the wait for debugger setting and then attaching to the process from within Android Studio. This, however, seems to make the bug go away. (The app is probably restarted.)
Q: How do I find the cause of the crash given these circumstances?
My intuition tells me that you are using some 'static' variables/fields in your application.
When your app goes to background and it is not used, system could drop process (because of memory management) of this application from memory. When you come back, Application object and all application proces in system is recreated, so all static variables are cleared/reinitialized.
Am i right?
Try looking into your logcat and if that is not an option for you. try some crash analytic like the following.
https://mint.splunk.com/
Integrate it in your app just with a single line and whenever your app get crashed you will receive a mail of your crash logs..
it will easily help you to determine your crash scenario..
And just out of curiosity are you using any singlton class in your Activity.?
I found the crash using adb as described here. Never realized that logcat keeps logs from previous executions. Nice!
I would like to add a feature of restarting from crash for my applications. So, I need to simulate the crash abort. It should be easy but I just can't make it crash itself.
It's a phonegap application, and the best would be crashed from the javascript in html. But no matter I tried, the application does not crash, the application is just hang there and not responding any clicks. I've tried to write some codes in the java phonegap plugins, however, I can't make it crash as well. Any suggestion?
Try something like this:
Object obj=null;
obj.toString();
This should cause a NullPointerException. When you don't catch it anywhere you should be able to test your recovery functionality. But think about a possibility to get bugreports from your users - elsewhere you will never be able to fix ugly bugs that happen only on other peoples devices.
My app has a splash screen activity and that starts an intent for the main activity which has an openGL view in it.
Some users are reporting that the game exits and goes back to the splash.
I'm certain that it's a bug, but it's failing silently and so I don't get any crash reports back.
What can cause it to fail silently like this? in such a way that the app cycles and no Force Close window is seen by the user.
Edit: I have stoped the splash screen restarting by putting noHistory="true" in the manifest for the slapsh activity. Now users just report that it exits silently. What would cause that?!
Edit2: If it's any clue, I recently updated from SDK r10 to SDK r16, I believe I have removed all other changes, I'd go back to r10 if I could, but I can't find a way.
Edit Jan 19: I have found the underlying cause of this problem. At some point google introduced to the SDK a feature called "png crush". And PowerVR is not always happy loading those textures. See my other question here for more info and solution.
Without source code, it is hard to tell what is really going on. Try debugging on emulators with different API levels and see if you can reproduce it.
If you can't get it reproduced, I suggest you take a look at ACRA and BugSense. Using those 3rd party crash reporting plugins is super easy and you can even report silent exceptions manually, too.
Are you using some native code? Because if there is a segment fault, it will print the stacktrace to logcat, but it won't create an Uncought Exception (so in this case plugins like ACRA are useless, even though I can recomment ACRA a lot)
It does happen to my applications as well, quite often during development-debug and it is usually due to the following problem.
The GPU goes in an out of memory status since there is too much memory allocated using VBOs. This usually depends on the fact not always the VBOs are deallocated correctly. When it does happen, in my humble experience, is like if the virtual machine hosting your application dies. Ufortunately it is evident that you cannot check the logcat of your users.
The problem is very variable since it depends on the GPU type and on the memory available to the GPU.
For instance on my galaxy tab, it happens after (in terms of loaded levels and therefore VBOs) my basic Motorola Defy.
This creates a lot of troubles in the troubleshooting.
:)
There is only way to rewrite default exception behavior - UncaughtExceptionHandler. You can create your own class ExceptionHandler implements UncaughtExceptionHandler and do with exceptions whatever you want - send it to you remote server or smth else. To register it you should create Application class:
public class YourApplication extends Application {
#Override
public void onCreate() {
super.onCreate();
Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this.getApplicationContext()));
}
}
and register this class in your manifest file
<application
android:name="your.package.name.YourApplication"
... >
...
</application>
Please note, unlike many other questions having the subject title "application has stopped unexpectedly", I am not asking for troubleshooting a particular problem.
Rather, I am asking for an outline of the best strategy for an Android/Eclipse/Java rookie to tackle this formidable task of digesting huge amounts of information in order to develop (and debug!) a simple Android application.
In my case, I took the sample skeleton app from the SDK, modified it slightly and what did I get the moment I try to run it?
The application
(process.com.example.android.skeletonapp)
has stopped unexpectedly. Please try
again.
OK, so I know that I have to look LogCat. It's full of timestamped lines staring at me... What do I do now? What do I need to look for?
Is there a way to single-step the program, to find the statement that makes the app crash? (I thought Java programs never crash, but apparently I was mistaken)
How do I place a breakpoint?
Can you recommend an Android debug tutorial online, other than this one?
I'm an Eclipse/Android beginner as well, but hopefully my simple debugging process can help...
You set breakpoints in Eclipse by right-clicking next to the line you want to break at and selecting "Toggle Breakpoint". From there you'll want to select "Debug" rather than the standard "Run", which will allow you to step through and so on. Use the filters provided by LogCat (referenced in your tutorial) so you can target the messages you want rather than wading through all the output. That will (hopefully) go a long way in helping you make sense of your errors.
As for other good tutorials, I was searching around for a few myself, but didn't manage to find any gems yet.
Filter your log to just Error and look for FATAL EXCEPTION
If you use the Logcat display inside the 'debug' perspective in Eclipse the lines are colour-coded. It's pretty easy to find what made your app crash because it's usually in red.
The Java (or Dalvik) virtual machine should never crash, but if your program throws an exception and does not catch it the VM will terminate your program, which is the 'crash' you are seeing.
Check whether your app has the needed permissions.I was also getting the same error and I checked the logcat debug log which showed this:
04-15 13:38:25.387: E/AndroidRuntime(694): java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.CALL dat=tel:555-555-5555 cmp=com.android.phone/.OutgoingCallBroadcaster } from ProcessRecord{44068640 694:rahulserver.test/10055} (pid=694, uid=10055) requires android.permission.CALL_PHONE
I then gave the needed permission in my android-manifest which worked for me.
From the Home screen, press the Menu key.
List item
Touch Settings.
Touch Applications.
Touch Manage Applications.
Touch All.
Select the application that is having issues.
Touch Clear data and Clear cache if they are available. This resets the app as if it was new, and may delete personal data stored in the app.