Closed wholybee closed 1 year ago
I finally got it working. Complete gradle files below:
Application:
plugins {
id "com.android.application" version "8.1.0" apply false
id "org.jetbrains.kotlin.android" version "1.8.0" apply false
id "org.jetbrains.kotlin.kapt" version "1.6.10" apply false
}
App:
plugins {
id "com.android.application"
id "org.jetbrains.kotlin.android"
id "org.jetbrains.kotlin.kapt"
}
android {
namespace 'net.example.myapplication'
compileSdk 33
defaultConfig {
applicationId "net.example.myapplication"
minSdk 31
targetSdk 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '17'
}
}
dependencies {
implementation "androidx.core:core-ktx:1.10.1"
implementation "androidx.appcompat:appcompat:1.6.1"
implementation "com.google.android.material:material:1.9.0"
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
implementation "androidx.fragment:fragment-ktx:1.6.1"
implementation "androidx.recyclerview:recyclerview:1.3.1"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.6.1"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.6.1"
implementation "androidx.room:room-runtime:2.5.2"
implementation "androidx.room:room-ktx:2.5.2"
kapt "androidx.room:room-compiler:2.5.2"
implementation "androidx.navigation:navigation-fragment-ktx:2.4.1"
//noinspection KaptUsageInsteadOfKsp
testImplementation "junit:junit:4.13.2"
androidTestImplementation "androidx.test.ext:junit:1.1.5"
androidTestImplementation "androidx.test.espresso:espresso-core:3.5.1"
}
...\WordDao.java:19: error: Not sure how to handle query method's return type (java.lang.Object). DELETE query methods must either return void or int (the number of deleted rows). public abstract java.lang.Object deleteAll(@org.jetbrains.annotations.NotNull
I see another bug report for this, and the suggested fixes (changing Room versions and/or kotlin versions) don't work. I have tried all the suggestions, as well as adding and Integer return type, removing the suspend, and updating all of the dependencies and kotlin to latest versions.
Maybe the tutorial is just broken on current Android studio and latest dependencies?