Maaz Zindani

Loading the index…

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

Jetpack Compose refuses to compile a Material API marked experimental

Your error

This material API is experimental and is likely to change or to be removed in the future.1 more line it can show

Fix it fast

Most common cause, 1 of 3

A Material 3 API that is still experimental is used without opt-in

Add @OptIn(ExperimentalMaterial3Api::class) to the composable that makes the call, or @file:OptIn at the top of the file.

Fix
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ModalBottomSheet

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun FilterSheet(onDismiss: () -> Unit) {
    ModalBottomSheet(onDismissRequest = onDismiss) { /* content */ }
}

// or, module-wide in build.gradle.kts
kotlin {
    compilerOptions {
        optIn.add("androidx.compose.material3.ExperimentalMaterial3Api")
    }
}
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

This material API is experimental and is likely to change or to be removed in the future is the opt-in message of ExperimentalMaterial3Api and of Material 2's ExperimentalMaterialApi. Kotlin stops the build until you add @OptIn with the matching marker. On material3 1.5.0 (BOM 2026.11.01) TopAppBar and its scroll behavior are stable, so upgrading removes that case.

  • Applies to Compose BOM 2026.11.01 (material3 1.5.0), androidx.compose.material 1.x (Material 2), Kotlin 2.x compiler
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

Go to the flagged line and check which package its composable is imported from. androidx.compose.material3 points to cause 1 or 2, androidx.compose.material (no 3) points to cause 3.

Run this first
grep -n "^import androidx.compose.material" app/src/main/java/com/example/app/MainActivity.kt

Then find the line you see in this list and open its fix:

  1. 1A Material 3 API that is still experimental is used without opt-inThe flagged call comes from androidx.compose.material3, for example ModalBottomSheet or rememberModalBottomSheetState
  2. 2An older material3 still marks TopAppBar as experimentalThe error sits on TopAppBar, LargeTopAppBar or a TopAppBarScrollBehavior, and the project resolves material3 1.4.x or older
  3. 3The call comes from Material 2, which uses a different markerThe import is androidx.compose.material.*, and adding ExperimentalMaterial3Api changed nothing

What does the error look like?

  • This material API is experimental and is likely to change or to be removed in the future.
  • This class or interface requires opt-in to be implemented: This material API is experimental and is likely to change or to be removed in the future.

Cause 1 of 3

A Material 3 API that is still experimental is used without opt-in

You seeThe flagged call comes from androidx.compose.material3, for example ModalBottomSheet or rememberModalBottomSheetState

Check

The message is the text that ExperimentalMaterial3Api declares through @RequiresOptIn, and Kotlin makes that level an error by default. Any call to a declaration carrying that marker, such as ModalBottomSheet in the current material3 source, fails until the caller opts in.

Check
grep -rn "ModalBottomSheet\|rememberModalBottomSheetState" app/src/main/java

Fix

Add @OptIn(ExperimentalMaterial3Api::class) to the composable that makes the call, or @file:OptIn at the top of the file. To accept the marker for the whole module, add it to the Kotlin compiler options instead.

Fix
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.ModalBottomSheet

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun FilterSheet(onDismiss: () -> Unit) {
    ModalBottomSheet(onDismissRequest = onDismiss) { /* content */ }
}

// or, module-wide in build.gradle.kts
kotlin {
    compilerOptions {
        optIn.add("androidx.compose.material3.ExperimentalMaterial3Api")
    }
}

Verify

The module compiles and the screen with the sheet renders.

Verify
./gradlew :app:compileDebugKotlin

Confirmed by kotlinlang.org

Did this fix it?

Cause 2 of 3

An older material3 still marks TopAppBar as experimental

You seeThe error sits on TopAppBar, LargeTopAppBar or a TopAppBarScrollBehavior, and the project resolves material3 1.4.x or older

Check

TopAppBar, LargeTopAppBar and several related bars lost their experimental marker in material3 1.5.0-alpha23, and TopAppBarScrollBehavior did in 1.5.0-alpha17, per the release notes. Projects on an older BOM still need the opt-in for that code.

Check
./gradlew :app:dependencies --configuration debugRuntimeClasspath | grep material3

Fix

Move to Compose BOM 2026.11.01, which maps to material3 1.5.0, and drop the opt-ins that now only cover stable calls. If you cannot upgrade yet, keep @OptIn(ExperimentalMaterial3Api::class) on the screens that use the bars.

Fix
// app/build.gradle.kts
dependencies {
    implementation(platform("androidx.compose:compose-bom:2026.11.01"))
    implementation("androidx.compose.material3:material3")
}

Verify

The dependency report shows material3 1.5.0, and TopAppBar compiles without any opt-in annotation.

Verify
./gradlew :app:dependencies --configuration debugRuntimeClasspath | grep material3

Confirmed by developer.android.com

Did this fix it?

Cause 3 of 3

The call comes from Material 2, which uses a different marker

You seeThe import is androidx.compose.material.*, and adding ExperimentalMaterial3Api changed nothing

Check

Material 2 declares its own ExperimentalMaterialApi with the very same message text, so the error looks identical. Opting into the Material 3 marker never covers a Material 2 call; the annotation class has to match the API's package.

Check
grep -rn "androidx.compose.material\." app/src/main/java | grep -v material3

Fix

Opt into androidx.compose.material.ExperimentalMaterialApi for that code, or replace the Material 2 component with its Material 3 counterpart so the app uses one design system.

Fix
import androidx.compose.material.ExperimentalMaterialApi

@OptIn(ExperimentalMaterialApi::class)
@Composable
fun LegacySheetScreen() {
    // Material 2 ModalBottomSheetLayout and friends
}

Verify

The build passes and no Material 2 import is left without its own opt-in.

Verify
./gradlew :app:compileDebugKotlin

Confirmed by android.googlesource.com

Did this fix it?

How do I stop it coming back?

  • Pin the Compose BOM in a version catalog and read the material3 release notes on each bump for APIs that graduated, then delete the stale opt-ins.
  • Prefer @OptIn on the single composable over a module-wide opt-in, so new experimental calls still show up in review.
  • If your own public function takes an experimental Material type as a parameter, annotate it with the marker itself; Kotlin's guide says the opt-in requirement then passes to its callers.

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 on the same stack: QistLock, Dispatch Pro, Nuclear Home Video.

Next step

Want this handled for good?

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