Android project with Java and Kotlin files, kapt or annotationProcessor?

First of all, the Kotlin Annotation processing tool (kapt) uses the Java compiler to run annotation processors. If your project contains any Java classes, kapt takes care of them by design. Kotlinlang recommends using kapt incase you used annotationProcessor from the Android Support before. JetBrains has a nice article about how kapt works in more … Read more

Android Room Persistence library and Kotlin

Usually in project build.gradle I define the dependencies versions: ext { buildToolsVersion = ‘25.0.2’ supportLibVersion = ‘25.3.1’ espressoVersion = ‘2.2.2’ archRoomVersion = ‘1.0.0-alpha1’ } so in app build.gradle the dependencies look like: dependencies { compile fileTree(dir: ‘libs’, include: [‘*.jar’]) compile “org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version” compile “com.android.support:appcompat-v7:${rootProject.supportLibVersion}” compile “android.arch.persistence.room:runtime:${rootProject.archRoomVersion}” annotationProcessor “android.arch.persistence.room:compiler:${rootProject.archRoomVersion}” kapt “android.arch.persistence.room:compiler:${rootProject.archRoomVersion}” androidTestCompile(“com.android.support.test.espresso:espresso-core:${rootProject.espressoVersion}”, { exclude group: ‘com.android.support’, module: … Read more

Room “Not sure how to convert a Cursor to this method’s return type”: which method?

Recently I’ve had the same problem but I was using Coroutines within the Dao function, e.g.: @Query(“SELECT * FROM Dummy”) suspend fun get(): LiveData<List<Dummy>> And was unable to compile, but after removing the suspend everything worked just fine. It’s not needed when returning LiveData. suspend and LiveData seem not to work together (as of now).

tech