· 6 min read

Android 17 Large Screens: The End of the Portrait Lock

Android 17 ignores portrait locks and resize limits on tablets and foldables, with no opt-out. Here is how I find and fix what breaks before 2027.

If your Android app locks itself to portrait, Android 17 has news for you. On large screens (tablets, foldables, desktop windows), apps that target API level 37 can no longer force an orientation, block resizing or limit the aspect ratio. Android 16 started this change but gave developers a way out. Android 17 removes it. This post covers what the Android 17 large screen change ignores, when it hits you, and the order in which I check a native app before the target SDK bump.

What Android 17 ignores on large screens

The rule applies when the smaller side of the display is 600 dp or more. On those screens, the system ignores these settings for apps that target API 37:

So this manifest no longer does what it says on a tablet:

<activity
    android:name=".MainActivity"
    android:screenOrientation="portrait"
    android:resizeableActivity="false"
    android:maxAspectRatio="2.0" />

The app opens full screen, in whatever orientation the user holds the device, and it can be resized in split screen or a desktop window.

There are limits to the rule. Phones under 600 dp are not affected, so your portrait lock still works on a normal phone. Apps marked as games with android:appCategory="game" are excluded. And users can still pick the app's requested behavior in the system's aspect ratio settings, but that is their choice, not yours.

The timeline and the missing opt-out

In Android 16 (API 36), Google made the same change but kept a temporary escape hatch: the PROPERTY_COMPAT_ALLOW_RESTRICTED_RESIZABILITY manifest property. Many teams used it to buy time, because Google Play required API 36 for new apps and updates from August 31, 2026.

Android 17 keeps the same behavior and drops the opt-out. Google's Android 17 post on resizability and orientation says Google Play will require API 37 for new apps and updates in August 2027.

Two things follow from that:

  1. If you used the opt-out, it keeps working only until you target API 37. The day you bump targetSdk, the protection is gone.
  2. August 2027 sounds far away, but the target SDK bump is never the only item in the sprint. Large screen bugs are layout and state bugs. They take longer to fix than to find.

Step 1: find out what breaks, before you bump the target

You can see the new behavior without changing targetSdk. On a debug build, the app compatibility framework has a flag that turns it on:

adb shell am compat enable UNIVERSAL_RESIZABLE_BY_DEFAULT com.example.app
adb shell am force-stop com.example.app

Run that on a tablet or a foldable emulator (Pixel Tablet and Pixel Fold are in Android Studio's device list) and walk through the app. I look at three things on every main screen:

Write down what breaks. The list usually falls into two groups: lost state and stretched layouts. They need different fixes, so I keep them apart.

Step 2: fix lost state first

By default, a rotation or a resize destroys and recreates the activity. If your app was locked to portrait, that path was almost never tested. Now every tablet user hits it.

The usual symptoms are a form that clears itself, a dialog that disappears, or a long operation that starts over. The fix is the old rule that a portrait lock let people ignore: state that matters lives outside the activity.

class DoorViewModel(
    private val savedState: SavedStateHandle,
    private val repository: DoorRepository,
) : ViewModel() {

    // Survives rotation and resize (ViewModel) and process death (SavedStateHandle).
    val selectedDoorId: StateFlow<String?> =
        savedState.getStateFlow("selectedDoorId", null)

    fun select(doorId: String) {
        savedState["selectedDoorId"] = doorId
    }

    // Long work runs in viewModelScope, so a rotation does not cancel it.
    fun refresh() = viewModelScope.launch { repository.refresh() }
}

Be careful with work that talks to hardware. If a request is tied to the activity's lifecycle, a rotation in the middle can cancel it and leave you waiting for a response that never comes. I wrote about one way to keep that work safe in Kotlin Flow for BLE responses: one place owns the connection, and the UI only observes it.

If your UI is in Jetpack Compose, you can also tell the system not to recreate the activity for size changes and let Compose recompose instead. Do this only after state is safe. Otherwise you hide the bug instead of fixing it.

Step 3: fix stretched layouts

A phone layout on a 10-inch tablet in landscape usually looks broken, not just big. Buttons stretch across the screen, text lines get too long, and the bottom of a form goes off screen.

You do not need a full tablet design to pass this. Two small changes fix most screens:

@Composable
fun AdaptiveScreen(content: @Composable () -> Unit) {
    Box(Modifier.fillMaxSize(), contentAlignment = Alignment.TopCenter) {
        Column(
            Modifier
                .widthIn(max = 600.dp)          // stop stretching on wide windows
                .fillMaxHeight()
                .verticalScroll(rememberScrollState()), // nothing goes off screen
        ) {
            content()
        }
    }
}

A max width keeps the phone layout readable in the middle of a wide window. A scroll container makes sure the last button is still reachable in landscape. Once that baseline works, you can decide which screens deserve a real two-pane layout. That decision is a product question, not a deadline one.

Camera screens need their own check. If you size a preview from the screen size, it will look wrong in a window. CameraX's PreviewView handles this for you.

Step 4: lock it in with tests

Manual checks find the bugs once. Tests keep them fixed. For Compose screens, DeviceConfigurationOverride lets a UI test render a screen at a forced size, so you can test a tablet layout on any emulator:

composeTestRule.setContent {
    DeviceConfigurationOverride(
        DeviceConfigurationOverride.ForcedSize(DpSize(1280.dp, 800.dp))
    ) {
        DoorListScreen()
    }
}
composeTestRule.onNodeWithText("Open").assertIsDisplayed()

For full flows, a Maestro or Espresso run on a tablet emulator in CI is enough to catch the worst regressions. Add one rotation step in the middle of a key flow. That single step tests state, layout and lifecycle at once.

If you need to win time for this work inside a bigger team, show it. A short screen recording of the app on a tablet emulator, before and after, explains the problem faster than any ticket text. People see the stretched button and the lost form, and the priority question answers itself.

Takeaways