From 49314fdd8c391d8271bd41e546bfd203b92b63b2 Mon Sep 17 00:00:00 2001 From: Petros Paraskevopoulos Date: Mon, 23 Sep 2024 19:13:39 +0300 Subject: [PATCH] Deps: add back eventbus android dependency This dependency was incorrectly removed and replaced by its corresponding 'eventbus-java' transitive dependency, assuming that is not required. However, after further testing it was revealed that this parent 'eventbus' dependency, which is actually 'android' specific is indeed necessary. If it is not provided on the classpath then an app will crash with the below runtime exception: ------------------------------------------------------------------------ java.lang.RuntimeException: Unable to create application xyz: java.lang .RuntimeException: It looks like you are using EventBus on Android, make sure to add the "eventbus" Android library to your dependencies. ------------------------------------------------------------------------ For more info see: - EventBus.register(...): https://github.com/greenrobot/EventBus/blob/ 0194926b3bcf70cc0d7bfd3c5da16708dd5ab876/EventBus/src/org/greenrobot/ eventbus/EventBus.java#L143-L147 - !AndroidDependenciesDetector.areAndroidComponentsAvailable(): https://github.com/greenrobot/EventBus/blob/ 0194926b3bcf70cc0d7bfd3c5da16708dd5ab876/EventBus/src/org/greenrobot/ eventbus/android/AndroidDependenciesDetector.java#L25-L36 --- WordPressUtils/build.gradle | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/WordPressUtils/build.gradle b/WordPressUtils/build.gradle index 1d6ed63c8..2a8971354 100644 --- a/WordPressUtils/build.gradle +++ b/WordPressUtils/build.gradle @@ -15,6 +15,7 @@ dependencies { implementation "com.google.android.material:material:$materialVersion" implementation "androidx.swiperefreshlayout:swiperefreshlayout:$androidxSwipeRefreshLayoutVersion" implementation "androidx.recyclerview:recyclerview:$androidxRecyclerViewVersion" + implementation "org.greenrobot:eventbus:$eventBusVersion" implementation "org.greenrobot:eventbus-java:$eventBusVersion" implementation "androidx.core:core:$androidxCoreVersion" @@ -29,6 +30,15 @@ dependencies { androidTestImplementation "androidx.test:runner:$androidxTestCoreVersion" } +dependencyAnalysis { + issues { + onUnusedDependencies { + // This dependency is actually needed otherwise the app will crash with a runtime exception. + exclude("org.greenrobot:eventbus") + } + } +} + android { namespace "org.wordpress.android.util"