https://kotlinlang.org
Join Slack
I would like to append an element to an IntArray, how would I do it in something simpler than this? ...
o

oday

over 4 years ago
I would like to append an element to an IntArray, how would I do it in something simpler than this?
var result = intArrayOf(1, 2, 3, 4)

val list = result.toMutableList()
list.add(5)

result = list.toIntArray
o
a
+3
  • 5
  • 12
  • 343
How do you read a txt file to a string in the JS target of a Kotlin Multiplatform project?
j

Justin

about 6 years ago
How do you read a txt file to a string in the JS target of a Kotlin Multiplatform project?
j
b
g
  • 3
  • 15
  • 343
I am running into a `java.lang.NoClassDefFoundError: kotlinx/serialization/json/Json` when executing...
t

Tobi

almost 7 years ago
I am running into a
java.lang.NoClassDefFoundError: kotlinx/serialization/json/Json
when executing tests in a multiplatform project. Any help would be much appreciated šŸ™
t
h
  • 2
  • 3
  • 343
I'm using a graphics layer and off-screen compositing to draw using blend modes (i.e. bitmap masking...
r

rob42

almost 2 years ago
I'm using a graphics layer and off-screen compositing to draw using blend modes (i.e. bitmap masking)
.graphicsLayer {
  compositingStrategy = CompositingStrategy.Offscreen
}
However, when I set the graphics layer to CompositingStrategy.Offscreen, my drawing is clipped to the composable's rect. Even when clip = false is set on graphicsLayer. Does anyone know how use blend modes without this clipping?
r
r
+3
  • 5
  • 16
  • 342
Hi guys, I want to use share same viewmodel instance in koin in jetpack compose navigation. I know t...
k

KotlinLeaner

almost 2 years ago
Hi guys, I want to use share same viewmodel instance in koin in jetpack compose navigation. I know there is a function in
koinViewModel()
to get instance of viewModel. I recently saw a Koin Documentation have separate
koin-androidx-compose-navigation
which gives a
koinNavViewModel()
function.
k
s
  • 2
  • 7
  • 342
Hello Everyone, I am working on a project using Jetpack Compose Multiplatform, and I have stumbled u...
k

KodePlateform

about 2 years ago
Hello Everyone, I am working on a project using Jetpack Compose Multiplatform, and I have stumbled upon an issue that I am finding challenging to solve. I have an SVG file that I converted into an XML drawable using Android Studio. The XML drawable contains paths with specific fill colors, and my goal is to dynamically replace a specific color attribute within the drawable with a color variable sourced from MaterialTheme at runtime. with attribute or android cvolors i got:
java.lang.IllegalArgumentException: Invalid color value ?attr/colorControlNormal or Invalid color value   @android:color/white
So is there a way to fill a specific path with for exemple MaterialTheme.colorScheme.onSurface ?
k
e
  • 2
  • 2
  • 342
Kotest builds with Gradle 7.6 are failing. Anyone seen this problem already? <https://github.com/kot...
e

Emil Kantis

about 3 years ago
Kotest builds with Gradle 7.6 are failing. Anyone seen this problem already? https://github.com/kotest/kotest/pull/3302
* What went wrong:
A problem occurred configuring project ':kotest-framework:kotest-framework-multiplatform-plugin-gradle'.
> Failed to notify project evaluation listener.
   > org.jetbrains.kotlin.gradle.plugin.KotlinGradleSubplugin: Provider org.jetbrains.kotlin.samWithReceiver.gradle.SamWithReceiverGradleSubplugin not a subtype
   > org.jetbrains.kotlin.gradle.plugin.KotlinGradleSubplugin: Provider org.jetbrains.kotlin.samWithReceiver.gradle.SamWithReceiverGradleSubplugin not a subtype
e
e
+2
  • 4
  • 5
  • 342
Is there any way to use `R.attr` references in a Compose Preview? We use attribute references &amp; ...
z

zsperske

about 3 years ago
Is there any way to use
R.attr
references in a Compose Preview? We use attribute references & themes for colors/drawables/text styles, however when running a preview they don’t resolve properly. This Composable fails to render a Preview.
@Preview
@Composable
fun MyComposable() {
   val attrPainter = attrPainter(R.attr.myAttr) //custom painter to get a drawable from an attr reference
   Image(attrPainter, contentDescription = "some description")
}
z
m
  • 2
  • 14
  • 342
I ran into problems with the `noCompress` option. I’m trying to load a tensorflow lite model from as...
h

Hadji Musaev

about 4 years ago
I ran into problems with the
noCompress
option. I’m trying to load a tensorflow lite model from assets in tests following this standard approach: https://www.tensorflow.org/lite/inference_with_metadata/lite_support Here’s a minimal version of the test that fails:
@RunWith(RobolectricTestRunner::class)

class MyTest {
    lateinit var interpreter: Interpreter

    @Before
    fun setUp() {
        val context = InstrumentationRegistry.getInstrumentation().targetContext
        val tfliteModel = FileUtil.loadMappedFile(context, "model.tflite")
        interpreter = Interpreter(tfliteModel)
    }
When I run it, it outputs
java.io.FileNotFoundException: This file can not be opened as a file descriptor; it is probably compressed
. However, I specified this in my gradle.build inside the
android{}
entry:
aaptOptions {
        noCompress("tflite")
    }
What could I be doing wrong? P.S. I apologise if this problem is not KMP specific šŸ˜…
h
  • 1
  • 1
  • 342
Is it possible to countĀ graphemesĀ instead of characters in pure kotlin (one that works in both jvm a...
m

Michal Klimczak

over 4 years ago
Is it possible to countĀ graphemesĀ instead of characters in pure kotlin (one that works in both jvm and native)? I'm looking for something like this but for pure kotlin:Ā https://stackoverflow.com/a/29743275/1118475. E.g. an emoji in utf16 will be counted as two characters withĀ 
emojiText.length
Ā and I would like a method which returnsĀ 
1
.
m
e
c
  • 3
  • 8
  • 342
Previous202203204Next

kotlinlang

A modern programming language that makes developers happier.

Powered by