Skip to content

Target Android 16 (API 36) - #135

Merged
dlukt merged 2 commits into
masterfrom
target-sdk-36
Sep 18, 2026
Merged

dlukt merged 2 commits into
masterfrom
target-sdk-36

Conversation

@dlukt

@dlukt dlukt commented Sep 18, 2026 •

Copy link
Copy Markdown
Owner

Google Play requires app updates to target API 36 (Android 16). From Nov 1, 2026, updates that don't can't be published.

What changed

  • compileSdk/targetSdk 35 → 36 in mastodon and appkit. AGP 8.10.1 already supports API 36, no plugin or Gradle upgrade needed.
  • CI installs platforms;android-36 (it was pinned to 35).
  • CI fix (separate commit): android-actions/setup-android no longer installs its default tools package. The sdkmanager on current runners (cmdline-tools 16.0) can't find that obsolete package, so every PR build has failed at that step since the runner image changed (last green run: June 29).
  • Back navigation, the only Android 16 behavior change that affects this app. Apps targeting 36 get predictive back on Android 16+, where the system no longer calls Activity.onBackPressed():
    • MainActivity: its onBackPressed() override returned to Home from a post opened via a notification or share. That logic moved to a new FragmentStackActivity.onInterceptBackPressed() hook, which runs from the existing OnBackPressedDispatcher callback. Without this, back on such a post closed the app.
    • PhotoViewer, ToolbarDropdownMenuController: these add their own windows and closed on KEYCODE_BACK. They now also register an OnBackInvokedCallback on API 33+. Their key handlers still work on Android 16/17 through an undocumented platform fallback for windows without a callback, so this is hardening rather than a fix (upstream Mastodon did the same). The key handlers stay for older Android versions.

The other API 36 changes don't apply: no edge-to-edge opt-out (already enforced at target 35), elegantTextHeight, orientation/resizability restrictions, scheduleAtFixedRate, health permissions or MediaStore.getVersion(). Safer intents and local network protection are opt-in.

Risk

Limited to back navigation. Android 13–15 keep the legacy back behavior (the app doesn't set enableOnBackInvokedCallback), and the old key handlers are still in place there. No visual changes.

Verification

  • ./gradlew :mastodon:assembleDebug :mastodon:testDebugUnitTest -x lint (the CI gate), :mastodon:minifyPlayReleaseWithR8 and :mastodon:lintDebug (nothing on changed lines). The APK declares targetSdkVersion 36.
  • New BackNavigationTest (instrumentation): 3/3 on an Android 17 (API 37) emulator. Against the old code at target 36, the MainActivity test fails because the activity closes.
  • On the emulator: the app launches, edge-to-edge renders correctly, back at the root exits (key and gesture), and a real back gesture closes the photo viewer through the new callback.
  • Not tested: flows that need a logged-in account, and Android 13–15 devices.

CI doesn't run instrumentation tests. To run this one: ./gradlew :mastodon:connectedDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=de.icod.techidon.test.BackNavigationTest

🤖 Generated with Claude Code

Google Play requires app updates to target API 36.

Raise compileSdk/targetSdk to 36 and install the matching platform in
CI. AGP 8.10.1 already supports it.

Apps targeting API 36 get predictive back by default on Android 16+:
the system no longer calls Activity.onBackPressed() and delivers back
through OnBackInvokedCallback instead. Adapt back handling:

- Move MainActivity's back logic (returning to the home screen from a
  post opened via a notification or share) out of onBackPressed() into
  a new FragmentStackActivity.onInterceptBackPressed() hook, which runs
  from the OnBackPressedDispatcher callback. Without this, back on such
  a post closed the app.
- Register OnBackInvokedCallbacks for the photo viewer and toolbar
  dropdown windows on API 33+. Their KEYCODE_BACK handlers still work
  today through an undocumented platform fallback for windows without
  a callback; the key handlers stay for older Android versions.

Add BackNavigationTest covering all three.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…kage

android-actions/setup-android installs "tools platform-tools" by
default. The sdkmanager on current GitHub runners (cmdline-tools 16.0)
can't find the long obsolete "tools" package and exits with an error,
so every PR build has failed since the runner image was updated. The
next step already installs the packages the build needs.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@dlukt
dlukt merged commit 12f3a48 into master Sep 18, 2026
2 checks passed
@dlukt
dlukt deleted the target-sdk-36 branch September 18, 2026 18:05
@dlukt
dlukt restored the target-sdk-36 branch September 18, 2026 18:06
@dlukt
dlukt deleted the target-sdk-36 branch September 18, 2026 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant