Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I am facing this error A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution

In my app I have a model class, it has some variables, I can call and show this data in this app using retrofit and room DB. which means this app first collects data from the server then it shows in room DB. But when I am using the list in this model class it shows this error. Here is my code

Movie.kt

@Entity(tableName = "movie_table")
data class Movie(
@SerializedName("Id")
@PrimaryKey(autoGenerate = true)
val id: Int,
@SerializedName("Title")
@Expose
val title: String,
@SerializedName("Year")
@Expose
val Year: Int,
@SerializedName("Actors")
@Expose
val actorDetails: List<Actor>
)

Actor.kt

data class Actor(
@SerializedName("ActorName")
@Expose
val actorName: String,
@SerializedName("ActorPoster")
@Expose
val actorImage: String
)

MovieDao.kt

@Dao
interface MovieDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertMovie(movie: Movie)

@Query("SELECT * FROM movie_table")
suspend fun getAllMovieDB(): List<Movie>
}

MovieDatabase.kt

@Database(
entities = [Movie::class],
version = 1
)
abstract class MovieDatabase : RoomDatabase() {
abstract fun getMovieDao(): MovieDao

companion object {
    @Volatile
    private var instance: MovieDatabase? = null
    private val LOCK = Any()

    operator fun invoke(context: Context) = instance
        ?: synchronized(LOCK) {
            instance
                ?: buildDatabase(context).also {
                    instance = it
                }
        }

    private fun buildDatabase(context: Context) = Room.databaseBuilder(
        context.applicationContext,
        MovieDatabase::class.java,
        "movieDatabase"
    ).build()

}
}

here is my fake JSON API enter link description here

here is the error enter image description here I can't find any error, I am also using analyze for get the error but it's show nothing. How can I solve this? Thank you.

like image 742
Adev Avatar asked Nov 24 '25 15:11

Adev


1 Answers

Just add the below lines to "gradle.properties"

kapt.use.worker.api=false
kapt.incremental.apt=false

The above solution is working for me.

like image 175
Dhaval Baldha Avatar answered Nov 27 '25 15:11

Dhaval Baldha



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!