mardi 6 juin 2023

Cannot get random color generator in Kotlin to work

Trying to generate a random color hexadecimal...Here's my code so far

import android.graphics.Color
import kotlin.random.Random
import kotlin.random.nextInt

fun main(){
    val rnd = Random.Default //kotlin.random
    val color = Color.argb(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256))
    }

This is the error I'm getting

Exception in thread "main" java.lang.RuntimeException: Stub!
    at android.graphics.Color.argb(Color.java:137)
    at com.example.functionexample.FunctionExampleKt.main(FunctionExample.kt:12)
    at com.example.functionexample.FunctionExampleKt.main(FunctionExample.kt)

Process finished with exit code 1

Tried searching for this error online but can't find anything. Theres no error messages on my actual code but when I run it I get that




Aucun commentaire:

Enregistrer un commentaire