Compose says RowScopeInstance is internal in the layout package
Cannot 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.
Fix it fast
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/main2Match what you see, then jump to its fix
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/src2Fix
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:compileDebugKotlinConfirmed by developer.android.com
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:compileDebugKotlinConfirmed by developer.android.com
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:
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- Nuclear Home VideoA video-streaming Android app built from scratch, engineered for smooth playback.
- Dispatch ProA real-time logistics platform: Flutter apps, Spring Boot services and a Kafka event pipeline on AWS.
Related fixes
Mobile apps
Android build fails because a product flavor has no flavor dimension
The flavor 'flavor_name' is not assigned to a flavor dimension.
Android Gradle plugin refuses to build when a product flavor is not assigned to a flavor dimension.
2 causes, each with a fixMobile apps
AGP 9 marks the android block as deprecated or fails on BaseExtension
java.lang.ClassCastException: class com.android.build.gradle.internal.dsl.ApplicationExtensionImpl$AgpDecorated_Decorated cannot be cast to class com.android.build.gradle.BaseExtension
AGP 9.0 uses only the new public DSL interfaces.
3 causes, each with a fixMobile apps
Android build fails because two libraries ship the same META-INF file
More than one file was found with OS independent path
Two dependencies put a file at the same path inside the APK and the plugin will not guess which one wins.
3 causes, each with a fixMobile apps
The editor cannot find R, so every R.string and R.id turns red
Unresolved reference: R
R is a class that the build generates from your res folder, in the package named by the module's namespace.
4 causes, each with a fixMobile apps
Android Studio says it could not identify the launch activity when you press Run
Run > Edit Configurations > Launch Options is set to Nothing or to a class that no longer exists
Android Studio launches the activity marked with a MAIN action and a LAUNCHER category in the merged manifest.
3 causes, each with a fixMobile apps
FirebaseInstanceIdService and FirebaseInstanceId.getToken() no longer work
Deprecation warning on FirebaseInstanceId.getInstance().getToken()
Move token handling into a class that extends FirebaseMessagingService and override onNewToken, which runs when a token is first created and whenever it changes.
2 causes, each with a fix