open-telemetry / opentelemetry-android

OpenTelemetry Tooling for Android
Apache License 2.0
114 stars 22 forks source link

Request to add dependency compatibility #466

Open jboxx opened 3 days ago

jboxx commented 3 days ago

Hi Contributors,

Want to request to add dependency compatibility for the

since there're a lot of users still use old dependencies, such as

Please apply low API for the demo also, so can reach many users

LikeTheSalad commented 2 days ago

Hi @jboxx

I think each of the tools/environments you mentioned could have a big enough discussion to have its own issue, although I'll try to summarise the status of each one below.

For Kotlin, we provide compatibility for the lowest possible version supported by the latest version of Kotlin, which as of now is 1.7. However, regardless of the efforts on Kotlin compatibility that we could make in this project and other OTel-related ones, ultimately it boils down to transitive dependencies that may not be adding that compatibility support for older versions, which is the case for OkHttp for example (as they mention here), which is a dependency for the OTel Java project as well as OTel Android, making the compatibility with older versions not possible as the Kotlin compiler complains when transitive dependencies do not set the Kotlin API and language versions to a lower one. So because of the way the Kotlin compiler handles this constraint on transitive dependencies, we cannot guarantee Kotlin support for older versions. An alternative "solution" to this problem could be to use older versions of said transitive dependencies for when they used an older version of Kotlin, however, this is not ideal both in terms of functionality and security, as older versions may not have bug fixes backported (as it's the case for OkHttp).

For the AGP older versions I don't think we have a specific feature that is causing problems with compatibility for older versions, however, I'm aware that Android Studio, and probably AGP itself tend to complain about compatibility based on the compileSdkVersion value, which is currently set to 34. The reason for us to use said version is because we add a couple of androidx dependencies that enforce the latest compileSdk values, otherwise AGP will refuse to compile the OTel Android lib until it uses the same version as the androidx libs. For this case, like the Kotlin issue there could also be an alternative "solution" which is to use older versions of the androidx libs, however, we tend to keep all dependencies up-to-date to make sure we provide the latest features and security fixes as soon as possible.

For the minSdk, both the OTel Java and the OTel Android projects provide compatibility for the API version 21 with the aid of the corelib desugaring tools that allow the SDK to use some extra Java 8 tools. The reason we use version 21 as the minimum is because it's also the minimum required by the Google Play Services, you can find more info on it here.

For the demo app, I think we could come up with some mechanisms to make sure it works on the oldest supported versions (it might be something already on the roadmap, I'll loop @breedx-splk in just to make sure I'm not mistaken).

To summarise, we do our best effort to keep compatibility with old versions as much as possible without compromising the proper functionality and security of the lib, which means that we tend to raise our minimum supported versions based on constraints enforced by our dependencies.