Skip to content

[Platform deprecation][Google] Migrate Android back handling before 2026-08-31 #5665

Description

@shai-almog

Impact summary

Urgency: Critical. Google Play has required new apps and updates to target Android 16 (API level 36) since 2026-08-31. On Android 16+, apps targeting API 36 no longer receive Activity.onBackPressed() or KeyEvent.KEYCODE_BACK; they must migrate to the supported predictive-back APIs or explicitly opt out temporarily.

Codename One still routes the Android system back action exclusively through CodenameOneActivity.onBackPressed(). With API 36 now the framework and cloud-build default, CN1 navigation can fail to receive back events on Android 16 devices. Depending on system fallback, a back gesture can bypass the CN1 form stack and leave/finish the activity instead of invoking the current form's back command.

Official requirement and deadline

Hard enforcement/submission deadline: 2026-08-31 (already passed).

First affected platform/store combination: apps targeting Android 16 / API 36, running on Android 16+, submitted as new apps or updates to Google Play from 2026-08-31.

Concrete Codename One applicability

Verified against codenameone/CodenameOne master at 134f6ec227792da11b595a77eda6c06d3c0a2b8f:

  • maven/codenameone-maven-plugin/src/main/java/com/codename1/builders/AndroidGradleBuilder.java
    • Gradle 8 builds raise the installed platform floor to API 36 (maxPlatformVersionInt = Math.max(36, ...)).
    • The generated app uses that value for targetSdkVersion unless android.targetSDKVersion overrides it.
    • Generated application stubs extend CodenameOneActivity by default (...Stub extends ... CodenameOneActivity).
  • Ports/Android/src/com/codename1/impl/android/CodenameOneActivity.java
    • onBackPressed() is the bridge that calls Display.keyPressed() and Display.keyReleased() with DROID_IMPL_KEY_BACK.
  • The default branch contains no OnBackInvokedDispatcher, OnBackInvokedCallback, AndroidX back dispatcher, or generated android:enableOnBackInvokedCallback handling.
  • codenameone/BuildDaemon master at 09cd713c6abe9455d0574ed0a1ff0776bee84754 generates the cloud-build stub extending CodenameOneActivity, so hosted builds consume the same affected port behavior.

Deduplication performed across open and closed issues/PRs using predictive back, onBackPressed, OnBackInvoked, API 36, the enforcement date, and the official notice name. No specific tracking item exists. The broad Android 16 warning in #4466 was closed with guidance to open a separate issue for concrete regressions; #5451 only changed the compile/target SDK default and did not change back dispatch.

Affected users and failure mode

  • All CN1 Android apps using the default API 36 target and running on Android 16+.
  • Apps with CN1 form back commands, toolbar back actions mapped to the hardware/system back event, dialogs, side menus, or custom key listeners are at risk.
  • Failure mode: the CN1 event is not dispatched, app-level back handling is skipped, predictive animation/navigation uses the activity default, or the activity exits rather than navigating within CN1.

Proposed migration

  1. Investigation
    • Reproduce on an Android 16 emulator with a generated API 36 CN1 app containing a two-form navigation stack, a dialog, and an in-place editor/IME case.
    • Confirm the behavior for gesture navigation and three-button navigation, including custom android.customActivity subclasses.
  2. Implementation
    • Register a lifecycle-safe OnBackInvokedCallback/dispatcher bridge on supported Android versions and route it through the existing CN1 DROID_IMPL_KEY_BACK pressed/released path.
    • Unregister it with the activity lifecycle and preserve IME/dialog priority semantics.
    • Keep pre-Android-13 behavior on older devices. Use a temporary manifest opt-out only as an emergency compatibility fallback, not the final migration.
    • Mirror any generated-source/build changes in codenameone/BuildDaemon.
  3. CI and beta validation
    • Add unit/static checks proving the callback is registered for modern targets and the legacy path remains intact.
    • Add Android 16 emulator UI coverage for form navigation, dialogs, side menus, text editing/IME dismissal, gesture back, and button back.
    • Build through both the Maven local path and hosted BuildDaemon path.
  4. Release and communication
    • Ship the port and builder/BuildDaemon halves together.
    • Call out the Android 16 back-navigation fix and any temporary opt-out build hint in release notes; notify users targeting API 36 to rebuild.

Internal target dates

The normal safety checkpoints were 2026-06-02 (90 days), 2026-07-02 (60 days), and 2026-08-01 (30-day release buffer). All are missed because enforcement began before this issue was filed.

Emergency recovery targets:

  • Investigation and reproducer: 2026-09-03
  • Implementation plus focused tests: 2026-09-04
  • Hosted/local beta validation: 2026-09-06
  • Release and customer communication: 2026-09-07

Risks, unknowns, and verification plan

  • Callback priority must not steal back from the IME, native peer dialogs, or Android-owned surfaces.
  • Custom activities may override lifecycle/back methods and need a documented integration seam.
  • A callback-only implementation restores semantics but may not provide full progress animations; decide whether OnBackAnimationCallback support is needed after correctness is restored.
  • Verify on Android 13-16, gesture and three-button navigation, with a generated release AAB targeting 36. Confirm logcat has no predictive-back warnings and that exactly one CN1 back event is delivered per action.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions