Skip to content

Xiaofei-it/HermesEventBus

⭐ 1,616  ·  Java  ·  GitHub Repo

A library for using EventBus between processes, useful in the IPC or plugin development.

1-Sentence Summary

Extends EventBus for seamless inter-process communication in Android, enabling simple cross-process event posting.

🔥 Key Capabilities & USP

  • Cross-Process Event Bus: Solves the fundamental limitation of standard EventBus by enabling event posting and receiving between different Android processes, not just within a single process.
  • Identical API to EventBus: Uses the exact same register(), post(), and @Subscribe annotations, meaning zero learning curve for teams already using EventBus. Migration is a simple dependency swap.
  • Automatic Process Routing: Designates one process as the main coordinator, automatically routing events from any sub-process through it and forwarding to all other processes. This eliminates the need for developers to manually manage IPC connections.
  • Built-in Concurrency & Cleanup: Integrates with Concurrent-Utils to handle deadlocks and race conditions inherent in IPC, and provides a destroy() method to prevent DeadObjectException during process teardown.
  • Inter-App Communication: Supports connecting separate apps via package name, enabling event-driven architectures across application boundaries.

USP: The only library that provides a drop-in replacement for EventBus that transparently handles IPC, making multi-process event-driven architecture as simple as single-process EventBus.

Architecture

Technical Architecture

ComponentRole
HermesAndroid IPC framework handling cross-process method invocation and data serialization
EventBusStandard in-process event distribution (v3.0.0)
Concurrent-UtilsResolves deadlocks and race conditions during IPC operations
Main ProcessDesignated coordinator process that receives all events and redistributes them

Flow: Event Posted → Hermes sends to Main Process → EventBus distributes locally → Hermes forwards to all Sub-Processes.

Quick Start Guide

1. Add Gradle dependency:

gradle
compile 'xiaofei.library:hermes-eventbus:0.3.0'

2. Initialize in Application class:

java
HermesEventBus.getDefault().init(this);

3. Register and post events:

java
// Register subscriber
HermesEventBus.getDefault().register(this);

// Post event
HermesEventBus.getDefault().post(new Event());

// Subscribe method
@Subscribe(threadMode = ThreadMode.MAIN)
public void showText(String text) {
    textView.setText(text);
}

4. Cleanup when done:

java
HermesEventBus.getDefault().destroy();

5. For inter-app communication, add service to AndroidManifest.xml:

xml
<service android:name="xiaofei.library.hermes.HermesService$HermesService0"/>

6. Connect other apps:

java
HermesEventBus.getDefault().connectApp(this, packageName);

Pros, Cons & Use Cases

Pros

  • Seamless migration for existing EventBus users – same API, same annotations.
  • Handles complex IPC plumbing automatically (routing, concurrency, cleanup).
  • Supports both intra-app and inter-app communication with minimal configuration.
  • Well-documented with clear initialization and cleanup lifecycle.

Cons

  • Locks to EventBus 3.0.0 – projects using older onEventXXX methods must refactor to @Subscribe annotations.
  • Requires explicit destroy() call – forgetting this can lead to DeadObjectException crashes.
  • External dependency chain – relies on both Hermes and EventBus libraries, adding to APK size and dependency management.
  • No Kotlin-first support – library is Java-based, though usable from Kotlin.

Who should NOT use this?

  • Single-process apps – if your app runs entirely in one process, standard EventBus is simpler and has fewer dependencies.
  • Projects using EventBus 2.x with onEventXXX methods – the refactoring effort may outweigh the benefits unless you need IPC.
  • Teams needing reactive streams (RxJava, Kotlin Flow) – this is a callback/annotation-based system, not a reactive pipeline.
  • Security-critical inter-app communication – IPC between apps has inherent security considerations that this library doesn't explicitly address.

Ideal Use Cases

  • Multi-process Android apps – apps with background services, content providers, or remote processes that need to share events.
  • Plugin architectures – host app communicating with plugin APKs running in separate processes.
  • App suites – multiple apps from the same developer that need real-time event synchronization (e.g., companion apps).
  • Migrating existing EventBus apps to multi-process architectures with minimal code changes.

Community & Activity

With 1,616 stars, HermesEventBus has strong community validation as a niche solution for a real pain point in Android development. The project solves a problem that many developers encounter when scaling apps beyond single-process architectures. While the last update was in 2026, the library is built on stable, mature dependencies (EventBus 3.0.0 and Hermes), so it's likely feature-complete and production-ready rather than abandoned. For teams already invested in the EventBus ecosystem, this is a well-engineered extension that fills a critical gap.

Project data from GitHub API, updated in real-time