From f10cffcb02a1ae37b436ea22eaf1cf67804927fe Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Thu, 13 Jan 2022 18:23:03 -0800 Subject: [PATCH] fix: ensure android can access native app instance before bootstrap --- packages/core/application/index.android.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/core/application/index.android.ts b/packages/core/application/index.android.ts index 94a165b25..e334f47b4 100644 --- a/packages/core/application/index.android.ts +++ b/packages/core/application/index.android.ts @@ -165,11 +165,15 @@ export { androidApp as android }; let mainEntry: NavigationEntry; let started = false; -export function run(entry?: NavigationEntry | string) { +function ensureNativeApplication() { if (!androidApp) { androidApp = new AndroidApplication(); appCommon.setApplication(androidApp); } +} + +export function run(entry?: NavigationEntry | string) { + ensureNativeApplication(); if (started) { throw new Error('Application is already started.'); @@ -233,6 +237,8 @@ export function getRootView(): View { } export function getNativeApplication(): android.app.Application { + ensureNativeApplication(); + // Try getting it from module - check whether application.android.init has been explicitly called let nativeApp = androidApp.nativeApp; if (!nativeApp) {