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

1.1.5 to 1.2.1 Migration - arrow.resilience.Schedule causes 'bad class file' error in Dagger KSP #3325

Open
postfixNotation opened this issue Dec 19, 2023 · 6 comments

Comments

@postfixNotation
Copy link

I migrated to the latest version of Arrow which made me add io.arrow-kt:arrow-resilience to use the Schedule class.
The import statement therefore changed from arrow.fx.coroutines.Schedule to arrow.resilience.Schedule and also arrow.fx.coroutines.retry to arrow.resilience.retry.

I'm using Dagger KSP version 2.49 and KSP version 1.9.21-1.0.16

When I build the module I get the following error message:

C:\Users\Me\AndroidStudioProjects\MyApp\app\build\generated\ksp\debug\java\com\...\dependencyinjection\app\AppModule_SomeClassFactory.java:5: error: cannot access SomeClass
import com.somepackage.SomeClass;
                                ^
  bad class file: C:\Users\Me\AndroidStudioProjects\MyApp\app\build\tmp\kotlin-classes\debug\com\...\SomeClass.class
    undeclared type variable: Input
    Please remove or make sure it appears in the correct subdirectory of the classpath.
C:\Users\Me\AndroidStudioProjects\MyApp\app\build\generated\ksp\debug\java\com\...\dependencyinjection\app\AppModule_SomeClassFactory.java:32: error: cannot find symbol
public final class AppModule_SomeClassFactory implements Factory<SomeClass> {
                                                                            ^
  symbol: class SomeClass
C:\Users\Me\AndroidStudioProjects\MyApp\app\build\generated\ksp\debug\java\com\...\dependencyinjection\app\AppModule_SomeClassFactory.java:67: error: cannot find symbol
  public SomeClass get() {
         ^
  symbol:   class SomeClass
  location: class AppModule_SomeClassFactory
C:\Users\Me\AndroidStudioProjects\MyApp\app\build\generated\ksp\debug\java\com\...\dependencyinjection\app\AppModule_SomeClassFactory.java:81: error: cannot find symbol
  public static SomeClass someClass(AppModule instance,
                ^
  symbol:   class SomeClass
  location: class AppModule_SomeClassFactory

So actually I cannot fully migrate from 1.1.5 to 1.2.1 using the lastest APIs/import statements.

@serras
Copy link
Member

serras commented Jan 23, 2024

Hi! Sorry for taking such a long time. This kind of problems usually happen when the names of type parameters do not coincide with the ones in the class. So I would like to ask some further question: how is the Schedule declared in your code?

@postfixNotation
Copy link
Author

This is one of two declaration variants in my code:

@OptIn(ExperimentalTime::class)
    private val retryPolicy = Schedule
        .exponential<Throwable>(10.milliseconds)
        .whileOutput { it < 3.seconds }

I know whileOutput was replaced with doWhile.

This is one of some use case variants in my code:

operator fun invoke(): Resource<SomeClient> {
        return resource(
            { retryPolicy.retry { someClientConnected() } },
            { someClient, _ -> someClient.endConnection() }
        )
    }

Hope this helps somehow!

@serras
Copy link
Member

serras commented Feb 8, 2024

It seems that there might be some problems because of incompatibilities between kapt and newer Kotlin versions. The solution seems to be to migrate to KSP-based Dagger. @postfixNotation could you maybe try it and report back?

@postfixNotation
Copy link
Author

Hi @serras,
I just double-checked. I'm using the most recent Dagger KSP and KSP plugin versions. None of the libraries I use for my module use KAPT. However, if I remove apply plugin: 'kotlin-kapt' from my app modules gradle file, there's an error message.

Dagger KSP:

implementation "com.google.dagger:dagger:$dagger_version"
ksp "com.google.dagger:dagger-compiler:$dagger_version"

Version numbers:

dagger_version = '2.50'
ksp_plugin_version = '1.9.22-1.0.17'

I tried to migrate yesterday again but I still get the same error message. I might be migrating from Dagger back to pure DI since Dagger won't become multiplatform in the foreseeable future. I also watched your keynote about context receivers which was pretty impressive.

@serras
Copy link
Member

serras commented Apr 16, 2024

@postfixNotation has this improved with 1.2.4?

@postfixNotation
Copy link
Author

@postfixNotation has this improved with 1.2.4?

@serras unfortunately it didn't.

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

No branches or pull requests

2 participants