I'm new to Kotlin and Android Studio and my current problem is this...
I'm trying get the Codelabs "android-room-with-a-view-kotlin" to work and whilst fixing various build errors along the way, I think my build.gradle has become very confused!
I corrected the last build failure at Word.kt by adding the dependency
kapt 'androidx.room:room-ktx:2.2.1'
The next build went a little further on to WordDao.kt but failed with the same type of error..
WordDao.java:21: error: To use Coroutine features, you must add `ktx` artifact from Room as a dependency. androidx.room:room-ktx:<version>
I'm unable to continue because I don't know what to change in the build.gradle as I've already added that dependency?
As I've said my file is now very confused and I would appreciate any assistance in making it more sensible. Thanks, DaveInUk
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: "kotlin-kapt"
android {
compileSdkVersion 28
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.prepopplus"
//was minSdkVersion 15 Note Old phone is API16
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
packagingOptions {
exclude "META-INF/atomicfu.kotlin_module"
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.50"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
kapt 'androidx.room:room-ktx:2.2.1'
kapt "androidx.room:room-compiler:2.2.1"
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0-rc01'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
kapt "android.arch.persistence.room:compiler:1.1.1"
kapt "android.arch.lifecycle:compiler:1.1.1"
implementation 'androidx.room:room-runtime:2.2.1'
}