Category "kotlin"

Overload equals of BigDecimal in Kotlin

In a Kotlin file I try to overload the equals method of the BigDecimal class. I have the following piece of code for that: fun BigDecimal.equals(n: Any?): Bool

assign variable only if it is null

on Ruby one have something like this: @var ||= 'value' basically, it means that @var will be assigned 'value' only if @var is not assigned yet (e.g. if @var

Gradle 6+ : compile groovy before kotlin

I'm working on a project combining groovy and kotlin. My Kotlin classes require objects from groovy part, how can i make gradle compile groovy before kotlin ?

kotlin dotenv doesn't take directory configuration

Trying to use kotlin-dotnet, but this is not working, using kotlin object class, to manage singleton Got error Could not find /asset/env on the classpath where

Android Jetpack DataStore Fatal Exception: java.io.IOException

Im using datastore in one of my android library and I get crashes from google vitals that I cant reproduce and should not be possible... I create my datastore a

how to use Coroutine in kotlin to call a function every second

i just created an app where my function getdata() call every second to fetch new data from server and updateui() function will update view in UI i don't use any

Is there a way to filter out null Any? values in Kotlin Map?

I'm trying to think of a function that would allow a Map<String, Any?> object to be treated as Map<String,Any> through type inference through applyi

FragmentFirstBinding Error with First Fragment XML Changes

I'm in Bumblebee v.2021.1.1. I don't have any database elements in my project. I do have defaults in the first fragment: import com.my.app.databinding.FragmentF

How to create a fat JAR with Gradle Kotlin script?

As titled, I'd like to know how to modify the gradle.build.kts in order to have a task to create a unique jar with all the dependencies (kotlin lib included) in

Jetpack Compose + Hilt: java.lang.RuntimeException: Cannot create an instance of class ViewModel

I started trying jetpack Compose recently and used hilt & hilt-navigation-compose for my app. It works fine with the first ViewModel. However, when I try th

No matching client found for package name "...." with different buildvariant

I want o implement push notification. I added to project level: dependencies { classpath 'com.android.tools.build:gradle:2.2.2' classpath 'com.

Modules that need to be instantiated by Hilt must have a visible, empty constructor

@Module @InstallIn(SingletonComponent::class) class WheelModule constructor(val size:Int) { @Provides fun provideWheel():Wheel = Wheel(size) } Module

Unresolved reference in kotlin with id and activity_main

I'm actually creating a new app in kotlin to display an xml file in boxes with the informations formatted To problem is that when I'm building the app, there i

How to create constructor of custom view with Kotlin

I'm trying to use Kotlin in my Android project. I need to create custom view class. Each custom view has two important constructors: public class MyView extend

Run espresso test multiple times

Sometimes I faced with rare bug in my application. But I can't reproduce it as it's very rare. So, I decided to write simple espresso test: @RunWith(AndroidJUn

Kotlin: return a value on button click

I'm just starting out on learning Kotlin, and I'm currently making a simple Quiz application for Android. The user can choose an answer with four buttons which

Android app link not working in android 12 always opening in browser

I have hosted assetlinks file into our domain https://ourdomain/.well-known/assetlinks.json And also verified this using https://developers.google.com/digital-a

How to suppress field from GraphQLClientRequest request body?

When I use ExpediaGroup graphql-kotlin client to call a GQL query, it inserts a field besides the query, variables and operationName. I understand this field co

How to see the type of variable within Android Studio IDE

How to see the type of variable in Android Studio when using Kotlin without type annotations. Currently I'm trying to see it by giving the variable a type I kn

Deprecated "getBitmap" with API 29. Any alternative codes?

My onActivityResult is not working because getBitmap is deprecated, any alternative codes to achieve this? here are the codes that needs to be changed, any sug