From d2d44e0dec8d218f387cdfa8c922ab22012857ac Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Sat, 31 Oct 2026 18:06:42 +0100 Subject: [PATCH] fix: stop the app from crashing at launch on android 14 and later --- android/app/src/main/AndroidManifest.xml | 5 +++-- .../screen-capture-permission.test.ts | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 src/lib/__tests__/screen-capture-permission.test.ts diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 5fd3bee1..a508ba48 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -9,8 +9,9 @@ - - + + diff --git a/src/lib/__tests__/screen-capture-permission.test.ts b/src/lib/__tests__/screen-capture-permission.test.ts new file mode 100644 index 00000000..982dca6e --- /dev/null +++ b/src/lib/__tests__/screen-capture-permission.test.ts @@ -0,0 +1,19 @@ +import { describe, expect, it } from 'vitest'; +import fs from 'node:fs'; +import path from 'node:path'; + +// expo-screen-capture calls Activity.registerScreenCaptureCallback on +// Android 14+ when its module loads. With DETECT_SCREEN_CAPTURE removed from +// the manifest that throws a SecurityException and the app crashed at launch. + +const root = path.resolve(__dirname, '../../..'); + +describe('screen capture permission', () => { + it('keeps DETECT_SCREEN_CAPTURE while expo-screen-capture is a dependency', () => { + const pkg = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8')); + expect(pkg.dependencies['expo-screen-capture']).toBeTruthy(); + const manifest = fs.readFileSync(path.join(root, 'android/app/src/main/AndroidManifest.xml'), 'utf8'); + expect(manifest).toMatch(//); + expect(manifest).not.toMatch(/DETECT_SCREEN_CAPTURE"\s+tools:node="remove"/); + }); +});