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

Not all classes included as part of project ABI when upgrading to Kotlin 2.0.21 #1360

Open
wbonnefond opened this issue Jan 22, 2025 · 2 comments

Comments

@wbonnefond
Copy link

Build scan link
Proprietary project :(

Plugin version
2.6.1

Gradle version
8.10.2

JDK version
17 (Corretto-17.0.10.7.1)

(Optional) Kotlin and Kotlin Gradle Plugin (KGP) version
2.0.21

(Optional) Android Gradle Plugin (AGP) version
8.7.2

(Optional) reason output for bugs relating to incorrect advice

Unused dependencies which should be removed:
  implementation(project(":diagnostics:common"))    <------ incorrect

These transitive dependencies should be declared directly:
  api("androidx.datastore:datastore-core:1.0.0")
  api("androidx.datastore:datastore-preferences-core:1.0.0")
  api(globalLibs.javaxInject)
  api(globalLibs.kotlinCoroutine)
  implementation("androidx.datastore:datastore:1.0.0")
  implementation("com.bugsnag:bugsnag-android-core:6.7.0")

Describe the bug
When upgrading from Kotlin 2.0.0 to Kotlin 2.0.21 the dependency analysis plugin begins to incorrectly mark some of our modules as unused in other modules, even though they are explicitly used. After digging into it a bit, I discovered that for some module dependencies in /reports/dependency-analysis/<variant>/<dependency>.json the files property is different.

  • Using kotlin 2.0.0, files is /Users/ward.bonnefond/Development/android/shared/diagnostics/common/build/classes
  • Using kotlin 2.0.21 files is/Users/ward.bonnefond/Development/android/shared/diagnostics/common/build/classes/java/main
Image

This no longer include the classes from /build/classes/kotlin as part of the module's ABI, so it gets marked as unused in most other modules that use it.

Image

I don't see this with every module though, so I don't know what has changed with Kotlin 2.0.21 here.

To Reproduce
Steps to reproduce the behavior:

  1. ...

Expected behavior

Additional context
I will try to get a reproducer project together, but it might take me a bit of time.

@autonomousapps
Copy link
Owner

Thanks for the issue and especially the preliminary debugging! Based on your observation that the path to the file has changed, I suspect the plugin is excluding things with "java" in them from Kotlin ABI analysis. Two questions:

  1. Can you confirm those generated classes were always Java? The class name suffix (_Factory) makes me think this is being generated by dagger.
  2. Can you provide a minimal reproducer? That would help with debugging and fixing the regression.

@wbonnefond
Copy link
Author

  1. The .class files here in /build/classes/java are not always from dagger generated classes. If the module has actual java code those class files will appear here as well.
  2. I tried to create a reproducer project but was unable to get the same behavior, the files property was a .jar file instead of a build directory.

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

No branches or pull requests

2 participants