Cannot access ‘‘: it is private in ‘MoshiConverterFactory’ //Android Kotlin Dev Diary

I’m starting a new category on my blog — Dev Diary, to document some of the errors that I encounter and what I did to fix them. I’m doing this in hopes of helping developers (including my future self!) as they work with code (and to get more blog visits! LOL). It’s nice to save time fixing a problem that you have already encountered and fixed before.

Today’s problem:

You are creating an instance of a class such as MoshiConverterFactory, but you get an error that says Cannot access '<init>': it is private in 'MoshiConverterFactory'

The solution:

Use the .create() method of the MoshiConverterFactory, like so:

.addConverterFactory(MoshiConverterFactory.create(moshi))

Related Posts:

Posts that may be related to "Cannot access ‘‘: it is private in ‘MoshiConverterFactory’ //Android Kotlin Dev Diary":

Catzie

A Filipino programmer with a variety of interests such as baking, singing, making up silly song/rap lyrics, K-pop, drawing, creating unique dessert flavors, obsessing about finding out how some things works, board games, anime, video games, and forgetting things that usually go in her long list of interests. Running small-time online dessert shops Cookies PH and Catzie's Cakery.

Leave a Reply

Your email address will not be published. Required fields are marked *