2
@Database(
    entities = [Account::class, ExtraInfo::class],
    version = 2,
    autoMigrations = [AutoMigration(from = 1, to = 2, spec = RoomDB.AutoMigration::class)])
abstract class RoomDB: RoomDatabase() {
    abstract fun RoomDAO(): RoomDAO

    @RenameColumn(tableName = "Account", fromColumnName = "importance", toColumnName = "viewCount")
    class AutoMigration: AutoMigrationSpec
...

this is part of my code.

As in the code above, I added the autoMigrations setting and built

Schema export directory is not provided to the annotation processor so we cannot import the schema.
To generate auto migrations, you must provide `room.schemaLocation` annotation processor argument AND set exportSchema to true.

Then the above error occurred.

@Database(
    entities = [Account::class, ExtraInfo::class],
    version = 2,
    autoMigrations = [AutoMigration(from = 1, to = 2, spec = RoomDB.AutoMigration::class)],
    exportSchema = true)
...

I added exportSchema = true to @Database and

defaultConfig {
    ...
    javaCompileOptions {
        annotationProcessorOptions {
            arguments += ["room.schemaLocation": "$projectDir/schemas".toString()]
        }
    } // added
    ...
}

I changed build.gradle(:app) as above.

  • What went wrong: Execution failed for task ':app:kaptDebugKotlin'.

A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution java.lang.reflect.InvocationTargetException (no error message)

Then this error occurred.

I've been looking for a solution on Google for a really long time, but I can't find it.

I don't know how the heck can I solve this

h j
  • 21
  • 1
  • 4
  • I think this question is duplicated with this https://stackoverflow.com/questions/62131564/a-failure-occurred-while-executing-org-jetbrains-kotlin-gradle-internal-kaptexec – Mohamed Saleh Mar 01 '22 at 14:09

0 Answers0