### Improved RxJava2 Crash Stack Trace Example Source: https://github.com/akaita/rxjava2debug/blob/master/README.md An example of a crash stack trace generated with RxJava2 assembly tracking enabled. It highlights how the 'Caused by' section now directly points to the user's faulty code within the RxJava2 pipeline, making debugging significantly easier. ```java FATAL EXCEPTION: main Process: com.akaita.fgas.debug, PID: 22538 java.lang.Throwable: The mapper function returned a null value. at io.reactivex.internal.functions.ObjectHelper.requireNonNull(ObjectHelper.java:39) at io.reactivex.internal.operators.observable.ObservableMap$MapObserver.onNext(ObservableMap.java:59) at hu.akarnokd.rxjava2.debug.ObservableOnAssembly$OnAssemblyObserver.onNext(ObservableOnAssembly.java:55) at io.reactivex.internal.operators.observable.ObservableSubscribeOn$SubscribeOnObserver.onNext(ObservableSubscribeOn.java:58) at hu.akarnokd.rxjava2.debug.ObservableOnAssembly$OnAssemblyObserver.onNext(ObservableOnAssembly.java:55) at io.reactivex.internal.operators.observable.ObservableScalarXMap$ScalarDisposable.run(ObservableScalarXMap.java:248) at io.reactivex.internal.operators.observable.ObservableJust.subscribeActual(ObservableJust.java:35) at io.reactivex.Observable.subscribe(Observable.java:10838) at hu.akarnokd.rxjava2.debug.ObservableOnAssemblyScalarCallable.subscribeActual(ObservableOnAssemblyScalarCallable.java:41) at io.reactivex.Observable.subscribe(Observable.java:10838) at io.reactivex.internal.operators.observable.ObservableSubscribeOn$SubscribeTask.run(ObservableSubscribeOn.java:96) at io.reactivex.Scheduler$DisposeTask.run(Scheduler.java:452) at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:61) at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:52) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:272) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:761) Caused by: caused by java.lang.NullPointerException: The mapper function returned a null value. at io.reactivex.internal.functions.ObjectHelper.requireNonNull(ObjectHelper.java:39) at com.akaita.fgas.activities.TopActivity.onResume(TopActivity.java:205) at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1269) at android.app.Activity.performResume(Activity.java:6766) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3377) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3440) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2713) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756) ``` -------------------------------- ### Enable RxJava2 Assembly Tracking Source: https://github.com/akaita/rxjava2debug/blob/master/README.md Starts collecting information about RxJava's execution to provide a more meaningful StackTrace in case of a crash. It's crucial to set up any crash-reporting handler before calling this method. ```java void enableRxJava2AssemblyTracking() ``` -------------------------------- ### Obscure RxJava2 Crash Stack Trace Example (Before Debugging) Source: https://github.com/akaita/rxjava2debug/blob/master/README.md An example of a typical, less informative RxJava2 crash stack trace without assembly tracking. This demonstrates the difficulty in identifying the root cause of an error when the stack trace does not clearly indicate the origin within the RxJava2 pipeline. ```java FATAL EXCEPTION: main Process: com.akaita.fgas.debug, PID: 27300 io.reactivex.exceptions.OnErrorNotImplementedException: The mapper function returned a null value. at io.reactivex.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:704) at io.reactivex.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:701) at io.reactivex.internal.observers.LambdaObserver.onError(LambdaObserver.java:74) at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.checkTerminated(ObservableObserveOn.java:276) at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.drainNormal(ObservableObserveOn.java:172) at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.run(ObservableObserveOn.java:252) at io.reactivex.android.schedulers.HandlerScheduler$ScheduledRunnable.run(HandlerScheduler.java:109) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756) Caused by: java.lang.NullPointerException: The mapper function returned a null value. at io.reactivex.internal.functions.ObjectHelper.requireNonNull(ObjectHelper.java:39) ``` -------------------------------- ### Get Enhanced Stack Trace for Throwable Source: https://github.com/akaita/rxjava2debug/blob/master/README.md Obtains a copy of the original Throwable with an extended StackTrace, providing more context about the RxJava execution flow leading to the exception. ```java @Nullable Throwable getEnhancedStackTrace(Throwable originalException) ``` -------------------------------- ### Enable Filtered RxJava2 Assembly Tracking Source: https://github.com/akaita/rxjava2debug/blob/master/README.md Starts collecting filtered information about RxJava's execution to provide a more meaningful StackTrace in case of a crash. Filtering is based on provided base package names. Any crash-reporting handler should be set up before calling this method. ```java void enableRxJava2AssemblyTracking(@Nullable String[] basePackageNames) ``` -------------------------------- ### Add RxJava2Debug Dependency using JCenter Source: https://github.com/akaita/rxjava2debug/blob/master/README.md This snippet demonstrates how to add the JCenter repository and the RxJava2Debug dependency to your project's build configuration. JCenter is an alternative to Maven Central for fetching the library. ```groovy repositories { jcenter() } dependencies { compile 'com.akaita.java:rxjava2-debug:1.4.0' } ``` -------------------------------- ### Configure RxJava2Debug for StackTrace Highlighting Source: https://github.com/akaita/rxjava2debug/blob/master/README.md This Java code snippet demonstrates how to enable RxJava2 assembly tracking and specify which package names should be prioritized and highlighted in generated stack traces. The `enableRxJava2AssemblyTracking` method takes an array of strings, where each string represents a package prefix. When an error occurs, RxJava2Debug will attempt to bring stack frames from these specified packages to the top of the trace, making it easier to identify the root cause within your application's codebase. ```Java RxJava2Debug.enableRxJava2AssemblyTracking(new String[]{"com.akaita.fgas", "com.akaita.android"}); ``` -------------------------------- ### Add RxJava2Debug Dependency using Maven Central Source: https://github.com/akaita/rxjava2debug/blob/master/README.md This snippet shows how to add the Maven Central repository and the RxJava2Debug dependency to your project's build configuration. This is a common way to include the library in your project. ```groovy repositories { mavenCentral() } dependencies { compile 'com.akaita.java:rxjava2-debug:1.4.0' } ``` -------------------------------- ### Enable RxJava2Debug Assembly Tracking in Android Application Source: https://github.com/akaita/rxjava2debug/blob/master/README.md This Java code demonstrates how to initialize RxJava2Debug within an Android Application's onCreate method. It enables assembly stack collection, ensuring enhanced and unique crash reports, especially when integrated with crash reporting tools like Crashlytics, by filtering stack traces to your specified package names. ```java public class MyApplication extends Application { @Override public void onCreate() { super.onCreate(); Fabric.with(this, new Crashlytics()); // Enable RxJava assembly stack collection, to make RxJava crash reports clear and unique // Make sure this is called AFTER setting up any Crash reporting mechanism as Crashlytics RxJava2Debug.enableRxJava2AssemblyTracking(new String[]{"com.example.myapp", "com.example.mylibrary"}); } } ``` -------------------------------- ### Configure RxJava2 Assembly Tracking Source: https://github.com/akaita/rxjava2debug/blob/master/README.md Enables the RxJava2 assembly tracking feature, which is crucial for generating detailed stack traces that pinpoint the origin of RxJava2 pipeline errors. ```java RxJava2Debug.enableRxJava2AssemblyTracking(); ``` -------------------------------- ### Obtain Enhanced Stack Trace for Handled RxJava2 Exceptions Source: https://github.com/akaita/rxjava2debug/blob/master/README.md This Java snippet shows how to use RxJava2Debug.getEnhancedStackTrace(throwable) within an RxJava onError handler. This allows developers to obtain a more meaningful stack trace even when exceptions are caught and handled, aiding in debugging and understanding the root cause of issues. ```java responseSubject .subscribe( responseObservable -> handleResponse(responseObservable), throwable -> RxJava2Debug.getEnhancedStackTrace(throwable) ); ``` -------------------------------- ### Disable RxJava2 Assembly Tracking Source: https://github.com/akaita/rxjava2debug/blob/master/README.md Disables the collection of additional information about RxJava's execution. Note that any information collected prior to calling this method will still be reported. ```java void disableRxJava2AssemblyTracking() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.