Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unresolved reference: enableEdgeToEdge in onCreate function JetPack Compose

I'm following Android Basic Course and the solution code provided has enableEdgeToEdge() function call in onCreate() in MainActivity. When I use this line of code, I get Unresolved reference: enableEdgeToEdge error.

Couldn't find a solution to it despite trying multiple imports and looking on the Internet for the issue. Any ideas on how to fix this?

Code available on GitHub: https://github.com/alghe-global/Kotlin/blob/4a25e707d4efc3edf09c7f637635adec8f6e876b/AndroidBasicsCourse/TipTime/app/src/main/java/com/example/tiptime/MainActivity.kt#L36

N.B. Solution code from Google is available @ https://github.com/google-developer-training/basic-android-kotlin-compose-training-tip-calculator/blob/29dddab0d5d911f1607bc5602249f89012f4d45e/app/src/main/java/com/example/tiptime/MainActivity.kt#L54

Trying to import androidx.activity.enableEdgeToEdge and call enableEdgeToEdge() in onCreate(...) gives the error Unresolved reference: enableEdgeToEdge on both the import enableEdgeToEdge and the function call enableEdgeToEdge()

like image 806
Alexandru Gheorghe Avatar asked Dec 30 '25 10:12

Alexandru Gheorghe


1 Answers

The Jetpack Compose team has introduced the enableEdgeToEdge() to avoid boilerplate code related to system bars like the status bar, navigation bar, etc.

You need to update to the latest version of implementation('androidx.activity:activity:1.8.1') to use enableEdgeToEdge features.

like image 64
Chirag Thummar Avatar answered Jan 06 '26 08:01

Chirag Thummar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!