I'm getting this error when building an Android app using Jetpack Compose:
e: ApprovalDetailScreen.kt:12:43 Cannot access 'val RowColumnParentData?.weight: Float': it is internal in file.
This happens even though the code uses the standard, documented pattern (Modifier.weight(1f) used correctly inside a Row/Column scope). The error persists after a full Clean + Rebuild, and after trying both platform() and enforcedPlatform() for the Compose BOM.
My current setup (app/build.gradle.kts and root build.gradle.kts):
The error occurs specifically at the import androidx.compose.foundation.layout.weight line, not at the actual usage sites further down in the file, which is unusual.
I've already tried:
What combination of versions would resolve this? Is there a known incompatibility between Compose BOM 2026.06.01 and Kotlin 2.2.10 specifically?
Full file causing the error:
package com.zenvira.portal.ui.approval
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.weight
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Card
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import com.zenvira.portal.domain.model.ApprovalComment
import com.zenvira.portal.domain.model.ApprovalDecisionStatus
import com.zenvira.portal.domain.model.PermissionAction
import com.zenvira.portal.domain.model.PermissionModule
import com.zenvira.portal.ui.permission.canDo
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun ApprovalDetailScreen(
onBack: () -> Unit,
viewModel: ApprovalDetailViewModel = hiltViewModel()
) {
val approval by viewModel.approval.collectAsState()
val comments by viewModel.comments.collectAsState()
val newComment by viewModel.newComment.collectAsState()
val decided by viewModel.decided.collectAsState()
val canApprove = canDo(PermissionModule.APPROVAL_CENTER, PermissionAction.APPROVE)
LaunchedEffect(decided) { if (decided) onBack() }
Scaffold(
topBar = {
TopAppBar(
title = { Text("Request Detail") },
navigationIcon = { IconButton(onClick = onBack) { Icon(Icons.Filled.ArrowBack, contentDescription = "Back") } }
)
}
) { padding ->
Column(modifier = Modifier.fillMaxSize().padding(padding)) {
approval?.let { a ->
Column(modifier = Modifier.padding(16.dp)) {
Text(a.entityLabel, style = MaterialTheme.typography.titleLarge)
Text(
"Submitted ${SimpleDateFormat("d MMM yyyy, h:mm a", Locale.getDefault()).format(Date(a.createdAt))}",
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
if (a.status == ApprovalDecisionStatus.PENDING && canApprove) {
Spacer(modifier = Modifier.height(16.dp))
Row(horizontalArrangement = Arrangement.spacedBy(12.dp)) {
Button(
onClick = { viewModel.decide(true) },
colors = ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.primary),
modifier = Modifier.weight(1f)
) { Text("Approve") }
OutlinedButton(
onClick = { viewModel.decide(false) },
modifier = Modifier.weight(1f)
) { Text("Reject") }
}
} else if (a.status == ApprovalDecisionStatus.PENDING) {
Spacer(modifier = Modifier.height(8.dp))
Text(
"Waiting for someone with approval permission to decide",
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
} else {
Spacer(modifier = Modifier.height(8.dp))
val color = if (a.status == ApprovalDecisionStatus.APPROVED) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.error
Text("Decision: ${a.status.name}", color = color, style = MaterialTheme.typography.titleMedium)
}
}
}
Text("Comments", style = MaterialTheme.typography.titleMedium, modifier = Modifier.padding(horizontal = 16.dp))
LazyColumn(
modifier = Modifier.weight(1f),
contentPadding = PaddingValues(16.dp),
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
items(comments, key = { it.id }) { comment -> CommentRow(comment) }
}
Row(
modifier = Modifier.fillMaxWidth().padding(16.dp),
verticalAlignment = androidx.compose.ui.Alignment.CenterVertically
) {
OutlinedTextField(
value = newComment,
onValueChange = viewModel::onCommentChange,
label = { Text("Add a comment") },
modifier = Modifier.weight(1f)
)
Spacer(modifier = Modifier.height(0.dp))
Button(onClick = viewModel::postComment, modifier = Modifier.padding(start = 8.dp)) {
Text("Post")
}
}
}
}
}
@Composable
private fun CommentRow(comment: ApprovalComment) {
Card(modifier = Modifier.fillMaxWidth()) {
Column(modifier = Modifier.padding(12.dp)) {
Text(comment.comment, style = MaterialTheme.typography.bodyMedium)
Text(
SimpleDateFormat("d MMM, h:mm a", Locale.getDefault()).format(Date(comment.createdAt)),
style = MaterialTheme.typography.labelSmall,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
}
}
}
The reason why you're getting that error is because you are importing an internal weight member from the RowColumnImpl.kt file that happens to be located in the same package:
// From Compose Foundation 1.13.0-alpha01 internal val RowColumnParentData?.weight: Float get() = this?.weight ?: 0f
The intended weight modifier you actually want to use is located within RowScope (see Modifier.weight within RowScope) and ColumnScope (see Modifier.weight within ColumnScope) rather than it being a top-level extension function:
public interface RowScope { // ... @Stable public fun Modifier.weight( @FloatRange(from = 0.0, fromInclusive = false) weight: Float, fill: Boolean = true, ): Modifier // ... } public interface ColumnScope { // ... @Stable public fun Modifier.weight( @FloatRange(from = 0.0, fromInclusive = false) weight: Float, fill: Boolean = true, ): Modifier // ... }
So there is no need to import any additional weight modifier as long as you are within a Row or Column scope (you can just use it directly):
@Composable fun Example() { Row(...) { // You get access to a RowScope within this trailing lambda Content(modifier = Modifier.weight(...)) } // Or with a Column Column(...) { // You get access to a ColumnScope within this trailing lambda Content(modifier = Modifier.weight(...)) } }
Modifier documentation has a section on Scope safety in Compose where there's a mention about Row/Column's weight modifier