-
Notifications
You must be signed in to change notification settings - Fork 87
Description
TL;DR
Testing opentelemetry-android with our documented minimum requirements (Kotlin 2.0, AGP 7.4) revealed compatibility issues:
- AGP 7.4 is not viable - fails with modern AndroidX libraries and D8 dexing errors
- Minimum AGP could be 8.0.2 - resolves the tooling issues
- OkHttp 5.3.2 forces Kotlin stdlib 2.2.21 - incompatible with our stated Kotlin 2.0 minimum
- Action needed: Either bump minimum Kotlin to 2.2 OR downgrade OkHttp dependency to v4 (how?)
- Missing requirement: We should define a minimum
compileSdkversion in VERSIONING.md. 34 is a good starting point, as it works with AGP 8.0.2. - Testing: We could add something like my test app to the CI, and verify that it builds with the minimum versions, at least to get some basic verification that the stated minimum requirements are correct.
Context
Following the discussion in #1489 about bumping the minimum Kotlin version to 2.0, I created a test app to verify all the compatibility claims made in our VERSIONING.md:
- Kotlin 2.0
- API 26
- AGP 7.4 and Gradle 7.5
- JDK 11 (build-time)
- Java language level 8
Test app repository: https://github.com/priettt/small-android-app
mainbranch: works without opentelemetry-androidotel-android-issuebranch: fails with opentelemetry-android
Issues found
1. AGP 7.4 incompatibility with modern AndroidX libraries
Error: checkDebugAarMetadata fails with lifecycle-runtime-ktx:2.9.x
Could not resolve androidx.lifecycle:lifecycle-runtime-ktx:2.6.1.
> The consumer was configured to find a runtime of a component, preferably optimized for Android,
as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.4.2'
Root cause: androidx.lifecycle:lifecycle-process:2.9.x uses multi-variant KMP metadata that AGP 7.4 cannot resolve.
Workaround: Downgrade to androidx.lifecycle:lifecycle-process:2.8.7
2. AGP 7.4 incompatibility with androidx.core
Error: checkDebugAarMetadata fails
Dependency 'androidx.core:core-ktx:1.17.0' requires Android Gradle plugin 8.9.1 or higher.
This build currently uses Android Gradle plugin 7.4.2.
Workaround: Downgrade to androidx.core:core:1.13.1
3. D8 dexing failures with AGP 7.4
Error: Multiple NullPointerException during dexing
ERROR:/Users/.../opentelemetry-exporter-sender-okhttp-1.57.0.jar: D8: java.lang.NullPointerException
ERROR:/Users/.../opentelemetry-api-1.57.0.jar: D8: java.lang.NullPointerException
[... many more similar errors]
Analysis: D8 in AGP 7.4 fails to process multiple OpenTelemetry artifacts. This appears to be a tooling limitation rather than a dependency issue.
Recommendation: Bump minimum AGP to 8.0.2 instead of continuing to downgrade dependencies.
4. Kotlin stdlib version conflict (Critical)
After bumping to AGP 8.0.2, a new issue appears:
Error: Kotlin metadata version incompatibility
e: Module was compiled with an incompatible version of Kotlin.
The binary version of its metadata is 2.2.0, expected version is 2.0.0.
Root cause: A transitive dependency is exposing kotlin-stdlib:2.2.21
Investigation: Running ./gradlew :app:dependencyInsight --dependency kotlin-stdlib --configuration releaseRuntimeClasspath reveals:
org.jetbrains.kotlin:kotlin-stdlib:2.2.21
+--- com.squareup.okhttp3:okhttp-android:5.3.2
\--- com.squareup.okhttp3:okhttp:5.3.2
\--- io.opentelemetry:opentelemetry-exporter-sender-okhttp:1.57.0
+--- io.opentelemetry.instrumentation:opentelemetry-instrumentation-bom-alpha:2.23.0-alpha
The culprit: okhttp3-android:5.3.2 (brought in by opentelemetry-instrumentation-bom-alpha:2.23.0-alpha)
Verification: Downgrading to opentelemetry-instrumentation-bom-alpha:2.17.1-alpha (last version using OkHttp 4) allows the build to succeed.
Proposed solutions
We have two options:
- Bump minimum Kotlin requirement to 2.2 in VERSIONING.md
- Downgrade OkHttp dependency in
opentelemetry-instrumentation-bom-alphato OkHttp 4 (if possible)
Additionally, we should:
- Update VERSIONING.md to reflect minimum AGP 8.0.2 (AGP 7.4 is not viable)
- Consider using
coreLibrariesVersionKotlin compiler extension to prevent future stdlib conflicts - Define minimum
compileSdkversion in VERSIONING.md (currently not specified). 34 may be a good starting point, as it works with AGP 8.0.2.
Questions
- Is it acceptable to bump the minimum Kotlin version to 2.2? I think not, it's too new.
- Can we downgrade the OkHttp dependency in the instrumentation BOM?
- Should we update our minimum AGP requirement to 8.0.2?