From 871211ca65345bcd655bbb8e9caaa1672cc2b521 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Wed, 21 Oct 2026 21:55:36 +0300 Subject: [PATCH] Declare camera as optional on Android so Chromebooks can install (#12035) Co-authored-by: Claude Opus 5.5 --- app.config.js | 1 + ...withAndroidManifestOptionalCameraPlugin.js | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 plugins/withAndroidManifestOptionalCameraPlugin.js diff --git a/app.config.js b/app.config.js index aad075c7f..93a336edb 100644 --- a/app.config.js +++ b/app.config.js @@ -353,6 +353,7 @@ module.exports = function (_config) { './plugins/withAndroidManifestLargeHeapPlugin.js', './plugins/withAndroidManifestFCMIconPlugin.js', './plugins/withAndroidManifestIntentQueriesPlugin.js', + './plugins/withAndroidManifestOptionalCameraPlugin.js', './plugins/withAndroidStylesAccentColorPlugin.js', './plugins/withAndroidNoJitpackPlugin.js', './plugins/withAndroidPreparedTextLayoutPlugin.js', diff --git a/plugins/withAndroidManifestOptionalCameraPlugin.js b/plugins/withAndroidManifestOptionalCameraPlugin.js new file mode 100644 index 000000000..ca1bfc3ba --- /dev/null +++ b/plugins/withAndroidManifestOptionalCameraPlugin.js @@ -0,0 +1,34 @@ +const {withAndroidManifest} = require('expo/config-plugins') + +/* + * Requesting the CAMERA permission makes Google Play assume we require a + * back-facing camera with autofocus, which hides the app from devices without + * one (most Chromebooks only have a front webcam). The camera is optional, so + * say so explicitly. + */ +const OPTIONAL_FEATURES = [ + 'android.hardware.camera', + 'android.hardware.camera.autofocus', +] + +module.exports = function withAndroidManifestOptionalCameraPlugin(appConfig) { + return withAndroidManifest(appConfig, function (decoratedAppConfig) { + const manifest = decoratedAppConfig.modResults.manifest + manifest['uses-feature'] = manifest['uses-feature'] || [] + + for (const name of OPTIONAL_FEATURES) { + const existing = manifest['uses-feature'].find( + feature => feature.$['android:name'] === name, + ) + if (existing) { + existing.$['android:required'] = 'false' + } else { + manifest['uses-feature'].push({ + $: {'android:name': name, 'android:required': 'false'}, + }) + } + } + + return decoratedAppConfig + }) +} -- knotmirror 0.0.1