Category "kotlin"

How to iterate over hashmap in Kotlin?

How to iterate over HashMap in Kotlin? typealias HashMap<K, V> = HashMap<K, V> (source)

Cannot create instance of viewmodel after using Hilt in Android

Here is my AllFilesListViewModel class. class AllFilesListViewModel @ViewModelInject constructor( private val pdfItemRepository: PdfItemRepository):ViewMod

Cannot create instance of viewmodel after using Hilt in Android

Here is my AllFilesListViewModel class. class AllFilesListViewModel @ViewModelInject constructor( private val pdfItemRepository: PdfItemRepository):ViewMod

Gradle can not find firebase auth ktx library in android

As you can see below, I have encounter this error when I try to download missing files inside firebase auth.ktx library otherwise I can not reach any document

Firebase recyclerview always refreshes and losses its scroll position when starting new activity and returning

My Firebase recycler view always refreshes and loses its scroll position when opening new activity and coming back. Tried multiple solution in Stack Overflow bu

My observer is always firing when I come back from one fragment to another

I'm using Navigation Components, I have Fragment A and Fragment B, from Fragment A I send an object to Fragment B with safe args and navigate to it. override f

java.lang.IllegalAccessError: class org.jetbrains.kotlin.kapt3.base.KaptContext Android

I've been getting an error like this for days, but I couldn't find a solution. Can you please help me? What could the problem be caused by? Error : java.lang.Il

In which situation val/var is necessary in Kotlin constructor parameter?

Right code: class MainActHandler(val weakActivity: WeakReference<Activity>): Handler() { override fun handleMessage(msg: Message?) { val true

Android studio code coverage not showing any Kotlin classes

I have 2 Kotlin based AS projects. One works fine, the other doesn't. Both have an identical structure and gradle config. I'm using Kotlin 1.1.4-2 with AS 3.0b2

How to avoid partial coverage with lateinit fields in Kotlin

I have an Android service written in Kotlin which I inject using Guice. It has lateinit fields which cannot be null, but they must be lateinit because I cannot

JaCoCo returning 0% Coverage with Kotlin and Android 3.0

I am trying to check my code coverage for a test case that I wrote in Kotlin. When I execute ./gradlew createDebugCoverageReport --info, my coverage.ec file is

Kotlin + Java 9 modules (Java 11 in use) + maven

I've created a simple project with Java and Kotlin code, and I'm trying to compile it as Java 9 module. Here is my pom.xml: <?xml version="1.0" encoding="UT

Invoke Operator & Operator Overloading in Kotlin

I get to know about the Invoke operator that, a() is equivalent to a.invoke() Is there anything more regarding Invoke operator than please explain. Also, I did

Default value for injection parameter

A simplified example: I have the following Koin module: val testModule = { factory<User> { (name: String) -> User(name) } } The Use

What's the difference between .kt and .kts files in Kotlin. When should we use .kts file over .kt file?

What is the purpose of using .kts files in Kotlin? Are these files included in the app bundle when releasing the app?

How to map a JSON string to Kotlin Map

I have a simple Kotlin program that access a Mongo database and produce a JSON string as below; "{ "_id" : { "$oid" : "593440eb7fa580d99d1abe85"} ,

Convert indefinitely running Runnable from java to kotlin

I have some code like this in java that monitors a certain file: private Handler mHandler = new Handler(); private final Runnable monitor = new Runnable() {

Android Studio is giving errors and warnings after enabling view binding. How to fix?

I am getting errors after i enabled view binding in my project. I have tried resyncing the project, invalidating cache. My app gradle file: apply plugin: 'com

CardView remove border

I want too remove a border on my cardView. I try set elavation to 0 dp , app:cardPreventCornerOverlap to false and app:cardUseCompatPadding to true , but I can

Room Persistence: Error:Entities and Pojos must have a usable public constructor

I'm converting a project to Kotlin and I'm trying to make my model (which is also my entity) a data class I intend to use Moshi to convert the JSON responses fr