question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Factory issues with kotshi 2.0-rc1

See original GitHub issue

Using kotshi:1.0.6 the following works

@KotshiJsonAdapterFactory
abstract class ApplicationJsonAdapterFactory : JsonAdapter.Factory {
    companion object {
        val INSTANCE: ApplicationJsonAdapterFactory = KotshiApplicationJsonAdapterFactory()
    }
}
...
moshi = Moshi.Builder().add(ApplicationJsonAdapterFactory.INSTANCE).build()

If I upgrade to kotshi:2.0-rc1 it no longer works Expression 'KotshiApplicationJsonAdapterFactory' of type 'KotshiApplicationJsonAdapterFactory' cannot be invoked as a function. The function 'invoke()' is not found

If I follow the latest in the README:

@KotshiJsonAdapterFactory
object ApplicationJsonAdapterFactory : JsonAdapter.Factory by KotshiApplicationJsonAdapterFactory
 ...
 moshi = Moshi.Builder().add(ApplicationJsonAdapterFactory).build()

This also doesn’t work Unresolved reference: KotshiApplicationJsonAdapterFactory

Is there something I’m missing here?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
ansmancommented, Mar 26, 2019

Man, I had hoped kapt would be better with this now. Anyway, the generated factory is an object in 2.0 so just remove your parentheses in the first example and that will still work

0reactions
ansmancommented, Apr 8, 2019

I haven’t found one and I’m not sure what to write if I were to file one since I can’t reproduce it consistently.

Read more comments on GitHub >

github_iconTop Results From Across the Web

kotshi - Freesoft.dev
An annotations processor that generates Moshi adapters from immutable Kotlin data classes. Moshi's default reflective adapters assume your ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found