-
Notifications
You must be signed in to change notification settings - Fork 146
Description
Build/Submit details page URL
https://expo.dev/accounts/j4ckr0y/projects/flouz/builds/80f0a894-78ea-4876-9b87-79648761f61b
Summary
Hi team,
I'm experiencing an issue with EAS Build that seems to be a bug in how prebuildCommand is executed. My build consistently fails during the Prebuild phase with an error indicating an unexpected --platform option.
Description of the problem:
I am running a build for the preview profile on the Android platform using the command:
eas build --profile preview --platform android
The build process successfully starts, but it fails during the Prebuild step. The logs show that EAS is attempting to run the prebuildCommand (npm run prebuild:preview) but is incorrectly appending the --platform android option to it, resulting in the following error:
npx expo npm run prebuild:preview --platform android exited with non-zero code: 1
unknown or unexpected option: --platform
This is unexpected behavior, as the prebuildCommand script itself, defined in package.json, does not expect this option. The script simply executes ts-node scripts/install-ads.js.
Expected Behavior:
The prebuildCommand (npm run prebuild:preview) should be executed by itself without any additional arguments from the eas build command. The --platform argument should only be used by the eas build command to determine the build environment, not passed down to the pre-build script.
EAS Build log URL:
https://expo.dev/accounts/j4ckr0y/projects/flouz/builds/80f0a894-78ea-4876-9b87-79648761f61b
Thank you for your help!
Managed or bare?
Managed Workflow
Environment
Environment:
EAS CLI Version: eas-cli/16.17.4 win32-x64
Expo SDK Version: 53.0.20
Node.js Version: node-v22.16.0
NPM Version: 11.4.2
Operating System: Windows 10 Pro
Error output
Build failed
npx expo npm run prebuild:preview --platform android exited with non-zero code: 1
Reproducible demo or steps to reproduce from a blank project
Steps to reproduce:
Set up a project with the provided package.json, eas.json, and install-ads.ts files.
Run the command eas build --profile preview --platform android.
Observe the build logs on the EAS dashboard. The build will fail during the "Prebuild" step with the mentioned error.
Relevant files:
Here are the contents of my relevant files to help you reproduce the issue.
eas.json
JSON
{
"cli": {
"version": ">= 16.9.0",
"appVersionSource": "remote"
},
"build": {
"development": {
"developmentClient": true,
"distribution": "internal",
"prebuildCommand": "npm run prebuild:dev",
"android": {
"buildType": "apk"
}
},
"preview": {
"distribution": "internal",
"prebuildCommand": "npm run prebuild:preview",
"android": {
"buildType": "apk"
},
"ios": {}
},
"production": {
"autoIncrement": true,
"prebuildCommand": "npm run prebuild:prod",
"android": {
"buildType": "app-bundle"
}
}
},
"submit": {
"production": {}
}
}
package.json
JSON
{
"name": "flouz",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"start": "expo start",
"android": "expo run:android",
"ios": "expo run:ios",
"web": "expo start --web",
"test": "jest --watchAll",
"test:ci": "jest --coverage --watchAll=false",
"test:single": "jest --watchAll=false",
"prebuild:dev": "ts-node scripts/install-ads-dev.js",
"prebuild:preview": "ts-node scripts/install-ads.js",
"prebuild:prod": "ts-node scripts/install-ads.js"
},
"expo": {
"doctor": {
"reactNativeDirectoryCheck": {
"listUnknownPackages": false
}
}
},
"dependencies": {
"@expo/metro-runtime": "~5.0.4",
"@expo/vector-icons": "^14.1.0",
"@react-native-async-storage/async-storage": "2.1.2",
"@react-native-picker/picker": "^2.11.1",
"@react-navigation/bottom-tabs": "^7.3.17",
"@react-navigation/native": "^7.1.8",
"@react-navigation/native-stack": "^7.3.21",
"@react-navigation/stack": "^7.3.1",
"expo": "53.0.20",
"expo-audio": "~0.4.8",
"expo-auth-session": "~6.2.1",
"expo-build-properties": "~0.14.8",
"expo-crypto": "~14.1.5",
"expo-file-system": "~18.1.9",
"expo-network": "~7.1.5",
"expo-status-bar": "~2.2.3",
"expo-system-ui": "~5.0.10",
"expo-web-browser": "~14.2.0",
"firebase": "^11.10.0",
"react": "19.0.0",
"react-dom": "19.0.0",
"react-native": "0.79.5",
"react-native-gesture-handler": "~2.24.0",
"react-native-reanimated": "~3.17.4",
"react-native-safe-area-context": "5.4.0",
"react-native-screens": "~4.11.1",
"react-native-svg": "15.11.2",
"react-native-web": "^0.20.0"
},
"devDependencies": {
"@testing-library/react-native": "^13.2.0",
"@types/jest": "^29.5.14",
"@types/react": "~19.0.10",
"jest": "~29.7.0",
"jest-expo": "~53.0.9",
"react-test-renderer": "19.0.0",
"typescript": "~5.8.3"
},
"private": true
}
scripts/install-ads.ts
TypeScript
// scripts/install-ads.ts
import { execSync } from 'child_process';
import * as fs from 'fs';
console.log('🚀 Installation automatique de react-native-google-mobile-ads...');
try {
// 1. Installer le package
execSync('npm install react-native-google-mobile-ads', { stdio: 'inherit' });
// 2. Installer expo-tracking-transparency si pas déjà fait
execSync('npx expo install expo-tracking-transparency', { stdio: 'inherit' });
// 3. Créer/modifier app.json pour les pubs
const appJsonPath = './app.json';
const appJson = JSON.parse(fs.readFileSync(appJsonPath, 'utf8'));
// Ajouter la config AdMob
if (!appJson['react-native-google-mobile-ads']) {
appJson['react-native-google-mobile-ads'] = {
android_app_id: process.env.ANDROID_ADMOB_APP_ID || "ca-app-pub-3940256099942544~1458002511",
ios_app_id: process.env.IOS_ADMOB_APP_ID || "ca-app-pub-3940256099942544~4354046892",
delay_app_measurement_init: true,
user_tracking_usage_description: "Cette app utilise des données pour personnaliser les publicités."
};
}
// Ajouter les plugins
if (!appJson.expo.plugins) {
appJson.expo.plugins = [];
}
// Plugin tracking
const trackingPlugin = [
'expo-tracking-transparency',
{
userTrackingPermission: 'Cette app utilise des données pour personnaliser les publicités.'
}
];
if (!appJson.expo.plugins.some(p => Array.isArray(p) && p[0] === 'expo-tracking-transparency')) {
appJson.expo.plugins.push(trackingPlugin);
}
// Sauvegarder app.json
fs.writeFileSync(appJsonPath, JSON.stringify(appJson, null, 2));
console.log('✅ Configuration AdMob ajoutée à app.json');
} catch (error) {
console.error('❌ Erreur lors de l\'installation:', error.message);
process.exit(1);
}