androidkotlinandroid-jetpack-composelogcat

Android Studio Showing Logcat but not my Log calls


Logcat is displaying all logs other than the ones I explicitly call for. Here is a small snippet of where the log call is nested within a Dropdown Menu

TextField(
    value = songVar,
    onValueChange = {
        songVarChanged(it)
        // more code here to assigning new value to selectedOptions.value
        Log.d("value", selectedOptions.value.toString())
    },
    label = { Text("name") },

When my dropdown box changes based on a value I select, I get no output named value or any string that should be in the list.

I checked back from a previous project where something similar worked within a checkbox. Nothing changed when I used my Samsung Galaxy S21 Ultra or if I used a Pixel 3a in the emulator. Same issue.


Solution

  • I tested your code snippet in Android Studio Koala, and everything seems to be ok - your command is executed in Logcat both on the simulator and on the real device, every time you enter/remove a character into/from a text field.

    Logcat window contains your Log.d prints

    fun songVarChanged(str: String): Unit { }
    
    @Composable
    fun CustomTextField() {
        val songVar = "Four Seasons"
        val selectedOption = remember { mutableIntStateOf(5) }
    
        Column(
            modifier = Modifier
                .fillMaxSize()
                .background(Color.Black),
            verticalArrangement = Arrangement.Center,
            horizontalAlignment = Alignment.CenterHorizontally
        ) {
            TextField(
                value = songVar,
                onValueChange = {
                    songVarChanged(it)
                    Log.d("VALUE_TAG", selectedOption.intValue.toString())
                },
                label = { Text("LABEL") },
            )
        }
    }