Android Room – simple select query – Cannot access database on the main thread

I am trying a sample with Room Persistence Library. I created an Entity: @Entity public class Agent { @PrimaryKey public String guid; public String name; public String email; public String password; public String phone; public String licence; } Created a DAO class: @Dao public interface AgentDao { @Query(“SELECT COUNT(*) FROM Agent where email = :email … Read more

What Java 8 Stream.collect equivalents are available in the standard Kotlin library?

In Java 8, there is Stream.collect which allows aggregations on collections. In Kotlin, this does not exist in the same way, other than maybe as a collection of extension functions in the stdlib. But it isn’t clear what the equivalences are for different use cases. For example, at the top of the JavaDoc for Collectors … Read more

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0

I’ve got a gradle FAILURE: …”Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.” Case description: Attached to the project codebase the next libs: APP/build.gradle //(Required) Writing and executing Unit Tests on the JUnit Platform testImplementation “org.junit.jupiter:junit-jupiter-api:5.2.0” testRuntimeOnly “org.junit.jupiter:junit-jupiter-engine:5.2.0” // (Optional) If you need “Parameterized Tests” testImplementation “org.junit.jupiter:junit-jupiter-params:5.2.0” // (Optional) … Read more

IllegalArgumentException: navigation destination xxx is unknown to this NavController

I am having an issue with the new Android Navigation Architecture component when I try to navigate from one Fragment to another, I get this weird error: java.lang.IllegalArgumentException: navigation destination XXX is unknown to this NavController Every other navigation works fine except this particular one. I use findNavController() function of Fragment to get access to … Read more

Accessing Kotlin extension functions from Java

Is it possible to access extension functions from Java code? I defined the extension function in a Kotlin file. package com.test.extensions import com.test.model.MyModel /** * */ public fun MyModel.bar(): Int { return this.name.length() } Where MyModel is a (generated) java class. Now, I wanted to access it in my normal java code: MyModel model = … Read more

What does the suspend function mean in a Kotlin Coroutine?

I’m reading Kotlin Coroutine and know that it is based on suspend function. But what does suspend mean? Coroutine or function gets suspended? From https://kotlinlang.org/docs/reference/coroutines.html Basically, coroutines are computations that can be suspended without blocking a thread I heard people often say “suspend function”. But I think it is the coroutine who gets suspended because … Read more