Issue
This is what I'm seeing when I try to build my project. I haven't changed anything except what Android forced me to in the Manifest and I don't know where to go after this.
Dao
@Dao
interface SubscriberDAO {
@Insert
suspend fun insertSubscriber(subscriber: Subscriber): Long
@Update
suspend fun updateSubscriber(subscriber: Subscriber): Int
@Delete
suspend fun deleteSubscriber(subscriber: Subscriber): Int
@Query("DELETE FROM subscriber_data_table")
suspend fun deleteAll(): Int
@Query("SELECT * FROM subscriber_data_table")
fun getAllSubscribers(): LiveData<List<Subscriber>>
}
What is wrong?
I tried to change the TargetSdk
back to 30 and it still didn't work
Gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 31
defaultConfig {
applicationId "com.homeofficeprojects.samplearchitecturedatabasecoroutinesproject"
minSdkVersion 21
targetSdkVersion 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
buildFeatures{
dataBinding = true
// for view binding :
// viewBinding = true
}
/*dataBinding{
enabled = true
}*/
}
dependencies {
def lifecycle_version = "2.4.0"
def room_version = "2.3.0"
kotlin {
experimental {
coroutines "enable"
}
}
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
// ViewModel
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
// LiveData
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
// Annotation processor
implementation("androidx.room:room-runtime:$room_version")
// To use Kotlin annotation processing tool (kapt)
kapt("androidx.room:room-compiler:$room_version")
// optional - Kotlin Extensions and Coroutines support for Room
implementation("androidx.room:room-ktx:$room_version")
annotationProcessor("androidx.room:room-compiler:$room_version")
//coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.cardview:cardview:1.0.0'
}
Subscriber
package com.homeofficeprojects.samplearchitecturedatabasecoroutinesproject
import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
@Entity(tableName = "subscriber_data_table")
data class Subscriber(
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "subscriber_id")
var id: Int,
@ColumnInfo(name = "subscriber_name")
var name: String,
@ColumnInfo(name = "subscriber_email")
var email: String
) {
//constructor(): this(0, "", "")
}
Edit: I've added the Gradle Build file and Subscriber kotlin class Edit 2: Second picture, more info on the errors
Solution
I ended up asking on reddit and was told to roll back the gradle dependency.
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
from
ext.kotlin_version = "1.6.0"
to
ext.kotlin_version = "1.5.31"
I'm not sure I would call that a way forward, but I can move on with my project so I'm calling it one until an actual answer comes through
Answered By - DJ. Aduvanchik
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.