tagged [kotlin]

In Gradle, is there a better way to get Environment Variables?

In Gradle, is there a better way to get Environment Variables? In several Tasks, I reference jars in my home folder. Is there a better way to get Environment Variables than This sets `$HOME` but I was...

warning: Kotlin runtime JAR files in the classpath should have the same version

warning: Kotlin runtime JAR files in the classpath should have the same version I get the following warning, but I'm not sure where v1.0.6 resides. Is it possible this error comes from a Kotlin librar...

3 Mar at 02:15

Unfortunately MyApp has stopped. How can I solve this?

Unfortunately MyApp has stopped. How can I solve this? I am developing an application, and everytime I run it, I get the message: > Unfortunately, MyApp has stopped. What can I do to solve this? --- [...

21 Jul at 22:35

Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6

Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6 When trying to run the Example CorDapp ([GitHub CorDapp](https://github.com/corda/cordapp-example...

23 Jul at 15:37

Kotlin Android start new Activity

Kotlin Android start new Activity I want to start another activity on Android but I get this error: > Please specify constructor invocation; classifier 'Page2' does not have a companion object after i...

Kotlin's data class == C#'s struct?

Kotlin's data class == C#'s struct? I used C# before and there we can define a `struct` which will be a value type. I'm learning Kotlin now and as far as I know kotlin `data-class` compares by value, ...

27 Dec at 15:35

Smart cast to 'Type' is impossible, because 'variable' is a mutable property that could have been changed by this time

Smart cast to 'Type' is impossible, because 'variable' is a mutable property that could have been changed by this time And the Kotlin newbie asks, "why won't the following code compile?": > Smart cast...

23 Jul at 21:1

Kotlin Error : Could not find org.jetbrains.kotlin:kotlin-stdlib-jre7:1.0.7

Kotlin Error : Could not find org.jetbrains.kotlin:kotlin-stdlib-jre7:1.0.7 I installed the Kotlin plugin into my app (v. v1.1.1-release-Studio2.2-1) and then selected "Configure Kotlin in Project" I...

20 Jun at 09:12

How to create empty constructor for data class in Kotlin Android

How to create empty constructor for data class in Kotlin Android I have 10+ variables declared in Kotlin data class, and I would like to create an empty constructor for it like how we typically do in ...

30 Nov at 10:39

Error: Execution failed for task ':app:clean'. Unable to delete file

Error: Execution failed for task ':app:clean'. Unable to delete file I'm trying to rebuild my Android Studio Gradle project (containing mostly Kotlin code), but it started to throw an `UnableToDeleteF...

What does the suspend function mean in a Kotlin Coroutine?

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? From [https://kotlinlang.org/docs...

Sort collection by multiple fields in Kotlin

Sort collection by multiple fields in Kotlin Let's say I have a list of People which I need to sort by Age first and then by Name. Coming from a C#-background, I can easily achieve this in said langua...

25 Mar at 21:59

Kotlin's List missing "add", "remove", Map missing "put", etc?

Kotlin's List missing "add", "remove", Map missing "put", etc? In Java we could do the following But if we rewrite it to Kotlin directly as below ``` class TempClass { var myList: List? = null fu

15 Sep at 21:44

Extend data class in Kotlin

Extend data class in Kotlin Data classes seem to be the replacement to the old-fashioned POJOs in Java. It is quite expectable that these classes would allow for inheritance, but I can see no convenie...

Union types in Java

Union types in Java I've been working with C# for a while and trying to get more familiar with Java. So I'm trying to migrate some of the basic patterns I use on daily basis in C# even only to underst...

16 Dec at 00:23

Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15

Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15 In [Stripe](https://en.wikipedia.org/wiki/Stripe_(company)), my clie...

Unresolved reference: kotlinx

Unresolved reference: kotlinx I am trying to try out Kotlin and the Kotlin Android extensions in Android Studio. I have tried this both in Android Studio v 1.5.1 on Ubuntu 14.04, and in Android Studio...

startForeground fail after upgrade to Android 8.1

startForeground fail after upgrade to Android 8.1 After upgrading my phone to 8.1 Developer Preview my background service no longer starts up properly. In my long-running service I've implemented a `s...

How do I exclude all instances of a transitive dependency when using Gradle?

How do I exclude all instances of a transitive dependency when using Gradle? My gradle project uses the `application` plugin to build a jar file. As part of the runtime transitive dependencies, I end ...

A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution

A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution All of sudden I start getting this error, and I am not getting idea why if anyone just let me know where this erro...

9 Oct at 11:38

Default interface methods are only supported starting with Android 7.0 (Nougat)

Default interface methods are only supported starting with Android 7.0 (Nougat) I upgraded to Android Studio 3.1 and I'm getting the following error: > Default interface methods are only supported sta...

10 May at 14:53

RecyclerView itemClickListener in Kotlin

RecyclerView itemClickListener in Kotlin I'm writing my first app in Kotlin after 3 years of experience with Android. Just confused as to how to utilize itemClickListener with a RecyclerView in Kotlin...

6 Feb at 16:23

Property initialization using "by lazy" vs. "lateinit"

Property initialization using "by lazy" vs. "lateinit" In Kotlin, if you don't want to initialize a class property inside the constructor or in the top of the class body, you have basically these two ...

3 Oct at 10:44

All com.android.support libraries must use the exact same version specification

All com.android.support libraries must use the exact same version specification After updating to android studio 2.3 I got this error message. I know it's just a hint as the app run normally but it's ...

Error : Program type already present: android.support.design.widget.CoordinatorLayout$Behavior

Error : Program type already present: android.support.design.widget.CoordinatorLayout$Behavior I am getting the following error while building the project. haven't used CoordinatorLayout in this proje...