google-developer-training/android-basics-kotlin-inventory-app

Android Basics: Persist data with Room

alionthego opened this issue · 1 comments

I've followed the examples precisely and get the following error when I create the Database class:

Execution failed for task ':app:kaptDebugKotlin'.

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

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

Before creating the class there are no errors when I build and I'm just beginning in Android so not really sure how to resolve this.

I'm using a macbook pro with the new M1 Max chip.

I've tried switching from
kapt "androidx.room:room-compiler:$room_version"
to
kapt "androidx.room:room-compiler:2.4.1" but then I get a different error:

error: cannot find symbol
import androidx.room.migration.AutoMigrationSpec;
^
symbol: class AutoMigrationSpec
location: package androidx.room.migration

I resolved this by changing the room version in all three dependencies:

// Room
implementation "androidx.room:room-runtime:2.4.1"
kapt "androidx.room:room-compiler:2.4.1"
implementation "androidx.room:room-ktx:2.4.1"