I am creating an android app, and i get spammed by a certain error(not affecting the app functionality). I have like 300k + errors in 5 seconds. I cannot view other errors from my app because of this spam.
Error is as following:
10-12 19:58:25.248 20268-20287/com.example.boacterapp.Pages E/ParseCommandCache﹕saveEventually thread had an error.
java.lang.IllegalStateException: Tried to serialize a command referencing a new, >unsaved object.
at com.parse.ParseCommand.resolveLocalIds(ParseCommand.java:472)
at com.parse.ParseCommand.onPreExecute(ParseCommand.java:371)
at com.parse.ParseRequest$7.then(ParseRequest.java:299)
at com.parse.ParseRequest$7.then(ParseRequest.java:296)
at com.parse.Task$11.run(Task.java:481)
at com.parse.Task$ImmediateExecutor.execute(Task.java:673)
at com.parse.Task.completeAfterTask(Task.java:477)
at com.parse.Task.continueWithTask(Task.java:353)
at com.parse.Task.continueWithTask(Task.java:364)
at com.parse.ParseRequest.executeAsync(ParseRequest.java:296)
at com.parse.ParseRequest.executeAsync(ParseRequest.java:286)
at com.parse.ParseCommandCache.maybeRunAllCommandsNow(ParseCommandCache.java:487)
at com.parse.ParseCommandCache.runLoop(ParseCommandCache.java:611)
at com.parse.ParseCommandCache.access$000(ParseCommandCache.java:26)
at com.parse.ParseCommandCache$2.run(ParseCommandCache.java:146)
Is there a way to apply a filter to exclude a certain error from the logcat?
Thank you in advance.
Try to change the filters in Logging with your package name
Attach a custom log_tag for each class at starting of the class
private static String LOG_TAG = MyClass.class.getName();
In Filter Configuration give your MyClass.class.getName() to filter out
In error log use Log.e(LOG_TAG,"message") this reduce number of loggings
Related
Every day I face with a lot of crash reports from the production mode by crashlytics on Android React Native. It is not possible to detect this crashes in the develop mode. Just stacktrace from firebase. And all this stacks describes what is happening on the native Java's side. By the name of the exception we can assume the approximate cause of the error. Some methods that was called before the crash and numbers of the lines that say nothing for you. And more over this methods could be called in so many places of the app, even in the third party libraries. In some lucky cases you can find the same errors maybe on GitHub or StackOverflow, but it is all individually, because if it works somewhere it does not mean it will work in your situation. And every day I try find the cause of the error in React Native app by test in many places of my app, but nothing to find there even if I now the approximate cause of the error from the stacktrace. Can somebody tell me please is it possible to detect the exact line code from Java side in React Native by this stacktrace or it is not enough information for it. Maybe to share your experience or recommend something how to go ahead at this. Thanks in advance!
Fatal Exception: android.view.WindowManager$BadTokenException: Unable to add window -- token android.os.BinderProxy#5f1e209 is not valid; is your activity running?
at android.view.ViewRootImpl.setView(ViewRootImpl.java:1122)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:439)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:95)
at android.app.Dialog.show(Dialog.java:473)
at com.facebook.react.views.modal.ReactModalHostView.showOrUpdate(ReactModalHostView.java:307)
at com.facebook.react.views.modal.ReactModalHostManager.onAfterUpdateTransaction(ReactModalHostManager.java:137)
at com.facebook.react.views.modal.ReactModalHostManager.onAfterUpdateTransaction(ReactModalHostManager.java:30)
at com.facebook.react.uimanager.ViewManager.updateProperties(ViewManager.java:51)
at com.facebook.react.uimanager.NativeViewHierarchyManager.createView(NativeViewHierarchyManager.java:279)
at com.facebook.react.uimanager.UIViewOperationQueue$CreateViewOperation.execute(UIViewOperationQueue.java:180)
at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:786)
at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:903)
at com.facebook.react.uimanager.UIViewOperationQueue.access$2400(UIViewOperationQueue.java:43)
at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:963)
at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:29)
at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:175)
at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:85)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:994)
at android.view.Choreographer.doCallbacks(Choreographer.java:794)
at android.view.Choreographer.doFrame(Choreographer.java:725)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:981)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7814)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1075)
Fatal Exception: java.lang.OutOfMemoryError
at android.graphics.Bitmap.nativeCreate(Bitmap.java)
at android.graphics.Bitmap.createBitmap(Bitmap.java:1095)
at android.graphics.Bitmap.createBitmap(Bitmap.java:1041)
at android.graphics.Bitmap.createBitmap(Bitmap.java:991)
at android.graphics.Bitmap.createBitmap(Bitmap.java:952)
at com.facebook.imagepipeline.memory.BucketsBitmapPool.alloc(BucketsBitmapPool.java:54)
at com.facebook.imagepipeline.memory.BucketsBitmapPool.alloc(BucketsBitmapPool.java:29)
at com.facebook.imagepipeline.memory.BasePool.get(BasePool.java:266)
at com.facebook.imagepipeline.platform.DefaultDecoder.decodeFromStream(DefaultDecoder.java:217)
at com.facebook.imagepipeline.platform.DefaultDecoder.decodeJPEGFromEncodedImageWithColorSpace(DefaultDecoder.java:155)
at com.facebook.imagepipeline.decoder.DefaultImageDecoder.decodeJpeg(DefaultImageDecoder.java:181)
at com.facebook.imagepipeline.decoder.DefaultImageDecoder$1.decode(DefaultImageDecoder.java:58)
at com.facebook.imagepipeline.decoder.DefaultImageDecoder.decode(DefaultImageDecoder.java:121)
at com.facebook.imagepipeline.producers.DecodeProducer$ProgressiveDecoder.doDecode(DecodeProducer.java:281)
at com.facebook.imagepipeline.producers.DecodeProducer$ProgressiveDecoder.access$200(DecodeProducer.java:128)
at com.facebook.imagepipeline.producers.DecodeProducer$ProgressiveDecoder$1.run(DecodeProducer.java:170)
at com.facebook.imagepipeline.producers.JobScheduler.doJob(JobScheduler.java:202)
at com.facebook.imagepipeline.producers.JobScheduler.access$000(JobScheduler.java:22)
at com.facebook.imagepipeline.producers.JobScheduler$1.run(JobScheduler.java:73)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at com.facebook.imagepipeline.core.PriorityThreadFactory$1.run(PriorityThreadFactory.java:51)
at java.lang.Thread.run(Thread.java:764)
First of all, try using try catch statements on all those places which you think can cause the crash like api calls, async functions, data processing etc.
There are multiple activity tracking sdk available out there for tracking activities like:
AppsFlyer: https://www.appsflyer.com/
Leanplum: https://www.leanplum.com/
CleverTap: https://clevertap.com/
You can use any of these sdk to track events/activities/errors. This will help you to identify steps to reproduce crash and sometimes this can provide you actual error message by passing it to the activity/event. You can get the error message in catch block and then pass that error message with the activity/event to the sdk.
I want to close my Android application with a method, but it should be shown a custom message (which I define for myself).
everything I found yet was "How to close my application" and I got more than 10 ways to close my application but I haven't found a way to set a custom message.
At the moment if my app crashes something like this appears:
[APPNAME] has been stopped
I want something like this
Congratulations! You found a bug, please submit it.
Is there even a way to do that? All methods I found just closed all activities or just forced an unresolveable error.
I don't think you need some code from me, but if you do, tell me.
(Language should be java and javascript/jQuery should be avoided)
You could try making a static stop method:
public static void stop(String message) {
Log.d(message);
System.exit(0);
}
In play framework, every time you get an Internal Server Error (500) in production mode, the browser shows a web page with
Oops, an error occured, This exception has been logged with id XXXX
I would like to customize the error message (or at least translate it to spanish), keeping the error id that makes it easier to look for in the application log.
I've tried to configure an error page in the Global settings in JAVA like this:
public Promise<Result> onError(RequestHeader request, Throwable t) {
return Promise.<Result>pure(internalServerError(
views.html.error.render(t)
));
}
Where I've a view named error.scala.html.
It is not working right now, it does not show any errors, just ignores it. Also with this alternative, I don't know how to display the error id.
I appreciate any suggestions, thanks a lot.
Is your Global class in the root package? That's a quite common mistake and also the reason why it is ignored.
In my android application I use a MediaPlayer to play a sound. However, the MediaPlayer expects a bunch of different listeners to be registered: onPreparedListener, onCompletionListener, onSeekCompleteListener, etc. Without them, the MediaPlayer spouts out error messages to logcat:
12-10 19:28:03.605: E/MediaPlayer(1820): mOnCompletionListener is null. Failed to send MEDIA_PLAYBACK_COMPLETE message.
My application does not need to do anything on these events, and so has no real need for the listeners. What's the standard way to deal with this? Should I register blank listeners? Should I not register any listeners? If so how do I turn off the error messages?
I'm not sure what API level you are using but these error messages don't appear to be in the Android source code for API 14+. The error messages were likely present in previous versions of Android's MediaPlayer class. If you have the latest SDK installed and the source code downloaded the class is located at: /sdk/sources/android-/android/media/MediaPlayer.java. Notice that the "TAG" variable is defined as:
private final static String TAG = "MediaPlayer";
And the OnCompletionCallback is set using:
public void setOnCompletionListener(OnCompletionListener listener)
{
mOnCompletionListener = listener;
}
This reaffirms my suspicion that you might be using an older SDK. Regardless, it would appear the easy fix would be to just add the listeners with empty callback methods. I hope this helps.
I have a JBOSS batch application that sometimes sends hundreds on emails in a minute to the same email address with Log4J errors. This causes problems with Gmail, because it says we are sending emails too quickly for that gmail account.
So I was wondering if there was a way to basically create a "digest" or "aggregate" email puts all the error logs in 1 email and sends that every 5 minutes. So that way every 5 minutes we may get a large email, but at least we actually get the email instead of it being delayed for hours and hours by gmail servers rejecting it.
I read this post that suggested something about using an evaluator to do that, but I couldn't see how that is configured in the Log4J xml configuration file. It also seemed like it might not be able to "digest" all the logs into 1 email anyway.
Has anyone done this before? Or know if it's possible?
From (the archived) SMTPAppender Usage page:
set this property
log4j.appender.myMail.evaluatorClass = com.mydomain.example.MyEvaluator
Now you have to create the evaluator class and implement the org.apache.log4j.spi.TriggeringEventEvaluator interface and place this class in a path where log4j can access it.
//Example TriggeringEventEvaluator impl
package com.mydomain.example;
import org.apache.log4j.spi.LoggingEvent;
import org.apache.log4j.spi.TriggeringEventEvaluator;
public class MyEvaluator implements TriggeringEventEvaluator {
public boolean isTriggeringEvent(LoggingEvent event) {
return true;
}
}
You have to write the evaluator logic within this method.
I created a free useable solution for log4j2 with an ExtendedSmtpAppender.
(If you still use log4j 1.x, simply replace your log4j-1.x.jar with log4j-1.2-api-2.x.jar - and log4j-core-2.x.jar + log4j-api-2.x.jar of course.)
You get it from Maven Central as de.it-tw:log4j2-extras (This requires Java 7+ and log4j 2.8+).
If you are restricted to Java 6 (and thus log4j 2.3) then use de.it-tw:log4j2-Java6-extras
Additionally, see the GitLab project: https://gitlab.com/thiesw/log4j2-extras (or https://gitlab.com/thiesw/log4j2-Java6-extras)
[OLD text:
If you use log4j2, see answer to other stack overflow issue: https://stackoverflow.com/a/34072704/5074004
Or directly go to my external but publically available solution presented in https://issues.apache.org/jira/browse/LOG4J2-1192
]