0

Sometime ago I wanted to use the new Material Components for Android
So I Followed their getting-started.md instructions and also updated to android studio 3.3 canary 6, and did all the migrate to androidx.

But after that I experienced some wired things, but the most bothering one is with moshi, I was using this code: ("it" is String with json)

        val moshi = Moshi.Builder()
                .add(KotlinJsonAdapterFactory())
                .build()

        val adapter = moshi.adapter(Events::class.java)
        val events = adapter.fromJson(it)

And when I build it's yelling:

e: Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
class com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory;, unresolved supertypes: Lcom.squareup.moshi.JsonAdapter.Factory;

Task :app:compileDebugKotlin FAILED

When I go to the declaration it is all good.

Does someone experienced it and know how to solve it? I'm not using proguard and disabled enableR8 in gradle.

Also I have those enabled:

android.enableJetifier=true
android.useAndroidX=true

-- Update --
After understanding that those the enableJetifier do, I created a new project only with moshi, did the same thing and with the enableJetifier to false it worked perfectly, BUT I must use the jetifier for dagger.

does anyone know how to exclude projects from jetifier?

Community
  • 1
  • 1
  • Are you building with Gradle? Make sure the moshi-kotlin artifact is in the dependencies for the module you are building. – Eric Cochran Aug 17 '18 at 23:17
  • I forgot to mention, I have those also: implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" implementation 'com.squareup.moshi:moshi:1.6.0' implementation 'com.squareup.moshi:moshi-kotlin:1.6.0' – user1840422 Aug 18 '18 at 08:38
  • I think this is a Jetifier bug. If disabling Jetifier works, please file a bug on Jetifier. – Eric Cochran Aug 20 '18 at 17:02

0 Answers0