Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

Compose says RowScopeInstance is internal in the layout package

ErrorCannot access 'RowScopeInstance': it is internal in 'androidx.compose.foundation.layout'

Short answer

RowScopeInstance is an internal class of Compose, so your code can never name it. Modifiers such as weight and align belong to RowScope, which is the receiver of the Row content lambda. Call them inside Row, or give your own composable a RowScope receiver so it can use them.

  • Applies to Compose Foundation 1.7, Kotlin 2, Android Studio
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Look at the line the error points at. If it names RowScopeInstance, or a weight or align call sits outside a Row block, one of the causes below applies.

    grep -rn "RowScopeInstance\|\.weight(\|\.align(" app/src/main
  2. 2Match what you see, then jump to its fix

    1. 1The words RowScopeInstance appear in your source, often after an auto-importCode references RowScopeInstance directlyFix
    2. 2The weight or align call sits in a separate @Composable function, not inside a Row blockweight or align is used in a helper composable outside the Row blockFix

What does the error look like?

  • Cannot access 'RowScopeInstance': it is internal in 'androidx.compose.foundation.layout'

Cause 1 of 2

Code references RowScopeInstance directly

1Check

Search for an import of androidx.compose.foundation.layout.RowScopeInstance or a call through it.

grep -rn "RowScopeInstance" app/src

2Fix

Delete the import and the reference. The public type is RowScope, the scope for the children of Row, and the modifiers come from the Row content lambda.

Row {
    Text("Left", Modifier.weight(1f))
    Text("Right")
}

3Verify

Rebuild. The internal access error is gone.

./gradlew :app:compileDebugKotlin

Confirmed by developer.android.com

Did this fix it?

Cause 2 of 2

weight or align is used in a helper composable outside the Row block

1Check

Modifier.weight and Modifier.align are members of RowScope, so they exist only where a RowScope is in scope. A plain composable function does not have one.

@Composable
fun Label() {
    Text("Hi", Modifier.weight(1f))   // no RowScope here
}

2Fix

Declare the helper as an extension on RowScope, and call it from inside a Row. The layout guide notes that modifiers are sometimes scope-specific.

@Composable
fun RowScope.Label() {
    Text("Hi", Modifier.weight(1f))
}

Row { Label() }

3Verify

Rebuild and check the preview.

./gradlew :app:compileDebugKotlin

Confirmed by developer.android.com

Did this fix it?

How do I stop it coming back?

  • Use RowScope, ColumnScope and BoxScope in signatures, never the internal *ScopeInstance classes.
  • When a modifier is not found, check that you are inside the matching layout block.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.