Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
R

RxJava2Debug

> 编程语言
Open source

RxJava 2.x extension to provide meaningful Stack Traces

654 stars0 likes1 views
WebsiteGitHub

About

RxJava 2.x extension to provide meaningful Stack Traces

RxJava2Debug

A library to make StackTraces involving RxJava2 more meaningful (they will always point to your code!).

Rationale

If you use RxJava2, you know the pain of debugging exceptions generated somwhere across the stream, in another thread, in a nested stream, ... The StackTrace provided by RxJava2 will tell you almost nothing. Even more, if you are using systems like Crashlytics to collect reports for and Android app, most RxJava-related crashes will be reported as a single error instance (omg, no way to fix that).

This library was created from the need to debug such situations when they happen in Android apps; even more, I needed to have a clear and precise report in Crashlytics for each distinct exception.

  1. If you handle exceptions generated in RxJava2 streams, you can query RxJava2Debug to obtain an extended StackTrace pointing to the exact line of code that created the issue.

  2. If you let exceptions generated in RxJava2 streams crash your app, RxJava2Debug will automatically extend the default StackTrace.

  3. If you let exceptions generated in RxJava2 streams crash your app and you configure RxJava2Debug with your package-names, RxJava2Debug will make sure you get unique reports for each issue (to Crashlytics, or whichever reporting system you use).

Installation

Using Maven Central :

groovy
repositories {
    mavenCentral()
}

dependencies {
    compile 'com.akaita.java:rxjava2-debug:1.4.0'
}

Using JCenter:

groovy
repositories {
    jcenter()
}

dependencies {
    compile 'com.akaita.java:rxjava2-debug:1.4.0'
}

Compatibility

RxJava2Debug 1.3.0+: RxJava 2.2.1+

RxJava2Debug 1.2.2: RxJava 2.1.0 to 2.2.0

Usage

Just enable RxJava2Debug as soon as possible. In Android, for example:

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"});
    }
}

This will:

  • Enhance stack traces of all RxJava2-related crashes making sure they contain a reference to the method that generated the first event in the Rx pipeline
  • Make sure that Stack Traces contain a reference to your code (some class in com.example.myapp or com.example.mylibrary)
  • Make sure that crash reports in Crashlytics are actually different for each pipeline (avoid bundling every RXJava error into one reports)

You will now also be able to obtain an enhanced Stack Trace even when you implement onError (really, you should implement it):

java
responseSubject
    .subscribe(
        responseObservable -> handleResponse(responseObservable),
        throwable -> RxJava2Debug.getEnhancedStackTrace(throwable)
    );
Without RxJava2Debug With RxJava2Debug

API

Start collecting information about RxJava's execution to provide a more meaningful StackTrace in case of crash
Beware: Any crash-reporting handler should be set up before calling this method

java
void enableRxJava2AssemblyTracking()

Start collecting filtered information about RxJava's execution to provide a more meaningful StackTrace in case of crash
Beware: Any crash-reporting handler should be set up before calling this method

java
void enableRxJava2AssemblyTracking(@Nullable String[] basePackageNames)

Disable the collection of more information about RxJava's execution
Information collected before calling this method will still be reported

java
void disableRxJava2AssemblyTracking()

Obtain a copy of the original Throwable with an extended StackTrace

java
@Nullable Throwable getEnhancedStackTrace(Throwable originalException)

Features

  • StackTrace generation
  • StackTrace filtering

StackTrace generation

Regardless of the thread a crash happens in, a nice StackTrace referring to the origin of the RxJava2 pipeline will be added to the causes of the crash.

Config:

java
RxJava2Debug.enableRxJava2AssemblyTracking();

Example (pointing to my own faulty code in com.akaita.fgas.activities.TopActivity.onResume(TopActivity.java:205)):

…

Instead of the obscure:

…

StackTrace filtering

Tell RxJava2Debug which packages names you want to highlight, and RxJava2Debug will make sure they appear as the top of the StackTrace

Config:

java
RxJava2Debug.enableRxJava2AssemblyTracking(new String[]{"com.akaita.fgas", "com.akaita.android"});

Result:

…

This comes in very handy when you work with a error reporting system such as Crashlytics.

Instead of getting a multitude of reports involving RxJava2 into a single report entry, you'll get one entry per crash.

Credits

This library is using a subset of classes from akarnokd's RxJava2Extensions.

RxJava2Extensions takes about 1mb and contains 5231 methods. RxJava2Debug takes about 38kb and contains 239 methods.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Javacrashcrash-reportingrxjava2stack-traces

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言