Search code examples
androidkotlinandroid-studio

Just getting started with Android Studio, can't figure out error


I am just getting started with Android Studio and running through the tutorials. I can't for the life of me figure out what I am doing wrong with a certain piece of code.

@Composable
fun GreetingText(from: String, message: String, modifier: Modifier = Modifier) {
    Text(text = message, fontSize = 100.sp, lineHeight = 116.sp)
    Text(text = from, fontStyle = 30.sp)
}

On the second Text call, I am getting an error stating that

"None of the following functions can be called with the arguments supplied"

and I can't seem to figure out why. I know it has to be something simple I am missing but not sure what it is.


Solution

  • Text(text = message, fontSize = 100.sp, lineHeight = 116.sp)
    

    Your second parameter here is fontSize. This takes a text size unit, such as the 100.sp that you are using.

    Text(text = from, fontStyle = 30.sp)
    

    Your second parameter here is fontStyle. This is not the same as fontSize and does not take a value like 100.sp. Either pass in a valid font style or perhaps change this from fontStyle to fontSize, if you intended to pass in a size.