Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Androidx migration #627

Closed
wants to merge 2 commits into from
Closed

Conversation

mdzyuba
Copy link

@mdzyuba mdzyuba commented Jan 7, 2020

Hello,

I would like to contribute an AndroidX upgrade as well as the project upgrade to the Android library (aar).

Thank you,

Mykola

@RocketRider
Copy link

This would be great, as I am trying to remove the jetifier in my project.

@eku
Copy link

eku commented Jan 16, 2020

@mdzyuba What is the benefit of this change? Can EventBus still be used with older environments or is an upgrade to AndroidX forced, which I found unacceptable.

@mdzyuba
Copy link
Author

mdzyuba commented Jan 19, 2020

@mdzyuba What is the benefit of this change? Can EventBus still be used with older environments or is an upgrade to AndroidX forced, which I found unacceptable.

The main benefit of this upgrade is to make EventBus compatible with projects that are using current Android libraries (AndroidX). This change does not restrict EventBus for older environments.

Currently EventBus depends on Android Support Libraries v.4.1.1.4 released in 2015. Google has deprecated Support Libraries and released an open source alternative - AndroidX in 2018. In order to keep the applications up to date with latest Android APIs, Android developers have to upgrade their projects to AndroidX. The process of migration to AndroidX is described here: https://developer.android.com/jetpack/androidx/migrate. Mixing Support Libraries and AndroidX libraries in any level of the dependency graph is problematic and not always possible. The Android Support Libraries classes had been moved to new Java packages under androidx.*. The new Android gradle plugin provides a Jetifier tool that migrates classes in Support Libraries v.28 to AndroidX v1.0 at the build time. However, is does not work well for older Android Support libraries, which is the case with EventBus. Here is the current code:

https://github.com/greenrobot/EventBus/blob/master/EventBus/build.gradle#L27
dependencies {
provided 'com.google.android:android:4.1.1.4'

Here is the Maven repository with details on the library release date:
https://mvnrepository.com/artifact/com.google.android/android/4.1.1.4
Date | (Dec 28, 2015)

If we want EventBus to be useful for the current Android development, we have to update its dependencies and migrate the code to AndroidX. This is the main goal of this pull request.

@Malachiasz
Copy link

Any update on that? Next to incremental build, dropping android support libs is the most important change to keep the library from dying.

@greenrobot-team
Copy link
Collaborator

Associated issue: #552

@Malachiasz Malachiasz mentioned this pull request Jun 3, 2020
@andob
Copy link
Contributor

andob commented Mar 14, 2021

@mdzyuba "Mixing Support Libraries and AndroidX libraries in any level of the dependency graph is problematic and not always possible."

what do you mean by that? can you give us some examples?

since 2018 until now I have been using EventBus with Jetifier extensively, got absolutely no problems.

@mdzyuba
Copy link
Author

mdzyuba commented Mar 15, 2021

@mdzyuba "Mixing Support Libraries and AndroidX libraries in any level of the dependency graph is problematic and not always possible."

what do you mean by that? can you give us some examples?

since 2018 until now I have been using EventBus with Jetifier extensively, got absolutely no problems.

Yes, Jetifier works and can be used. However, there are a few reasons not to do that. Here are some.

Generally, mixing two versions of the same library used by different dependencies in the same apk leads to build time issues and requires extra work on resolving conflicts in dependencies.

Mixing different versions of the same android support libraries is not safe. It can lead to crashes. Please see https://stackoverflow.com/questions/42374151/all-com-android-support-libraries-must-use-the-exact-same-version-specification and https://stackoverflow.com/questions/53938393/android-studio-library-error-mixing-versions-can-lead-to-runtime-crashes-and-a for more details.

Even if mixing libs does not lead to crashes, it leads to duplication of code. Removing the duplication in builds takes extra work.
Also, running Jetifier takes time. This post https://adambennett.dev/2020/08/disabling-jetifier/ shows that disabling Jetifier improves build speed.

Jetifier was designed as a temporary solution to help with transitioning from android support libs to androidX. There is no reason to keep using it if the project can move to AndroidX.

@ooyellow58
Copy link

it is a pity not to migrate to AndroidX

@greenrobot-team
Copy link
Collaborator

@ooyellow58 See #552 (comment) A preview release with Android X support is now available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants