Skip to content

Android openWindow uses an undeclared Activity class after the original Activity finishes #11526

Open

Description

@rafaelaugustos

Observed behavior

On Android, Application.openWindow() can throw ActivityNotFoundException after the original/primary Activity has finished, even while another NativeWindow from the app remains open.

Observed with NativeScript core/runtime 9.1.1 on an Android 15/API 35 arm64 emulator, using com.tns.NativeScriptActivity and launchMode="standard". The remaining secondary window could still navigate, but requesting another window attempted to launch org.nativescript.NativeScriptActivity, which was not declared in the manifest.

Reproduction

  1. Configure a multi-instance launch Activity and a window content resolver.
  2. Launch the primary window and open a secondary one with Application.openWindow().
  3. Finish the original Activity while leaving the secondary window alive.
  4. From the remaining window, call Application.openWindow() again.

Observed exception:

android.content.ActivityNotFoundException: Unable to find explicit activity class
{org.nativescript.vuerouterns/org.nativescript.NativeScriptActivity};
have you declared this activity in your AndroidManifest.xml ...?

Expected behavior

Use a valid NativeScript Activity class from a surviving owned window (or the application's configured launch component) when the initial Activity no longer exists. Closing one document window should not prevent another from opening further windows.

Suspected cause

AndroidApplication.openWindow() uses this.startActivity to select the target class. If it is absent, it falls back to a hard-coded class name. Activity destruction can clear startActivity, even though a secondary NativeWindow still has an Activity.

A possible direction is to consult the surviving primary/owned NativeWindow's Activity before using a class-name fallback; the policy should avoid accidentally reopening an unrelated SDK Activity that happens to be foreground.

Source: https://github.com/NativeScript/NativeScript/blob/main/packages/core/application/application.android.ts

Found while validating multi-window routing in rafaelaugustos/vue-router-ns#46. This report concerns the native openWindow request itself, independently of route matching.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions