From d7b1923cdfd3aa99b4136de444ee264df3692c8d Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 23 Nov 2026 13:43:32 +0000 Subject: [PATCH] fix(android): declare screen.portrait and wifi as optional features for Google Play Play Console blocked the 2.2.0 review with "Required hardware feature declarations are restricting your app's availability" for android.hardware.screen.portrait and android.hardware.wifi (Phone, Tablet, Desktop, Android XR). Neither is declared anywhere; Play infers both as required: - screen.portrait from `orientation: 'portrait'`, which locks MainActivity to portrait; - wifi from the ACCESS_WIFI_STATE permission that @react-native-community/netinfo adds. Both predate 2.1.0, so this is Play's newer check, not a regression. A new config plugin declares both with android:required="false" (plus tools:replace so a library can't OR it back to required). An explicit declaration stops Play inferring the feature, so the portrait lock and the permission stay while the install restriction goes. Checked with `expo prebuild --platform android`: the generated manifest carries both entries and the tools namespace. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_015YMpaaKrSMPdcrBZg2i498 --- app.config.ts | 5 +++ plugins/withOptionalHardwareFeatures.js | 60 +++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 plugins/withOptionalHardwareFeatures.js diff --git a/app.config.ts b/app.config.ts index 4c38d8120..8aef3d4c2 100644 --- a/app.config.ts +++ b/app.config.ts @@ -342,6 +342,11 @@ export default ({ config }: ConfigContext): ExpoConfig => ({ // vision DEPENDENCIES meta-data; merge them so the Android manifest merger // does not fail. See plugins/withMlkitVisionDependencies.js. './plugins/withMlkitVisionDependencies.js', + // Declares screen.portrait (inferred from `orientation: 'portrait'`) and + // wifi (inferred from netinfo's ACCESS_WIFI_STATE) as not required, so + // Google Play neither blocks review nor hides the app from devices without + // them. See plugins/withOptionalHardwareFeatures.js. + './plugins/withOptionalHardwareFeatures.js', // Sets SWIFT_ENABLE_EXPLICIT_MODULES=NO so the Swift pods (NitroModules, // RCTSwiftUI) don't fail the app target's "Emit Swift module" phase on // Xcode 16+. Vendored from @onramper/onramper-react-native's own plugin diff --git a/plugins/withOptionalHardwareFeatures.js b/plugins/withOptionalHardwareFeatures.js new file mode 100644 index 000000000..25a2187a7 --- /dev/null +++ b/plugins/withOptionalHardwareFeatures.js @@ -0,0 +1,60 @@ +const { withAndroidManifest } = require('@expo/config-plugins'); + +/** + * Expo config plugin: declare the hardware features Google Play infers for us + * as optional, so the store does not hide the app from devices without them. + * + * Neither feature is declared anywhere; Google Play infers both as REQUIRED: + * - android.hardware.screen.portrait, from `orientation: 'portrait'` in + * app.config.ts, which locks MainActivity to portrait. + * - android.hardware.wifi, from the ACCESS_WIFI_STATE permission that + * @react-native-community/netinfo adds to read the connection type. + * Play Console then blocks review with "Required hardware feature declarations + * are restricting your app's availability" (Phone, Tablet, Desktop, XR). + * + * The app needs neither: it works over any network, and on a device without a + * portrait screen Android shows the portrait layout letterboxed. Declaring a + * feature explicitly stops Play inferring it, so `android:required="false"` + * keeps the portrait lock and the permission while dropping the install + * restriction. `tools:replace` makes ours win if a library ever declares the + * same feature as required (the merger otherwise ORs `required` to true). + * + * See https://developer.android.com/develop/ui/compose/layouts/adaptive/increase-app-availability + * + * android/ is prebuild-generated (gitignored), so this re-applies on every + * `expo prebuild`. + */ +const OPTIONAL_FEATURES = ['android.hardware.screen.portrait', 'android.hardware.wifi']; +const TOOLS_NAMESPACE = 'http://schemas.android.com/tools'; + +module.exports = function withOptionalHardwareFeatures(config) { + return withAndroidManifest(config, config => { + const manifest = config.modResults.manifest; + + // `tools:replace` is only valid when the tools namespace is declared. + manifest.$ = manifest.$ || {}; + if (!manifest.$['xmlns:tools']) { + manifest.$['xmlns:tools'] = TOOLS_NAMESPACE; + } + + manifest['uses-feature'] = manifest['uses-feature'] || []; + + for (const name of OPTIONAL_FEATURES) { + const attributes = { + 'android:name': name, + 'android:required': 'false', + 'tools:replace': 'android:required', + }; + const existing = manifest['uses-feature'].find( + item => item.$ && item.$['android:name'] === name, + ); + if (existing) { + existing.$ = { ...existing.$, ...attributes }; + } else { + manifest['uses-feature'].push({ $: attributes }); + } + } + + return config; + }); +};