Auth0导致Expo托管工作流EAS构建失败,寻求解决方案
Expo EAS构建失败:AndroidManifest占位符未替换问题
构建错误日志
Task :expo-linear-gradient:bundleLibCompileToJarRelease > Task :app:mergeReleaseResources > Task :app:processReleaseMainManifest /home/expo/workingdir/build/HalfBaked1/android/app/src/main/AndroidManifest.xml Error: Attribute data@host at AndroidManifest.xml requires a placeholder substitution but no value for <auth0Domain> is provided. /home/expo/workingdir/build/HalfBaked1/android/app/src/main/AndroidManifest.xml Error: Attribute data@scheme at AndroidManifest.xml requires a placeholder substitution but no value for <auth0Scheme> is provided. See https://developer.android.com/r/studio-ui/build/manifest-merger for more information about the manifest merger. > Task :app:processReleaseMainManifest FAILED > Task :expo-location:compileReleaseJavaWithJavac Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: /home/expo/workingdir/build/HalfBaked1/node_modules/expo-location/android/src/main/java/expo/modules/location/taskConsumers/GeofencingTaskConsumer.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. > Task :expo-permissions:compileReleaseKotlin > Task :expo-notifications:compileReleaseKotlin w: file:///home/expo/workingdir/build/HalfBaked1/node_modules/expo-notifications/android/src/main/java/expo/modules/notifications/permissions/NotificationPermissionsModule.kt:39: Error: Gradle build failed with unknown error. See logs for the "Run gradlew" phase for more information.
当前app.json配置
{ "expo": { "name": "HalfBaked1", "slug": "HalfBaked1", "owner": "jsummers1329", "scheme": "myapp", "version": "1.0.0", "orientation": "portrait", "icon": "./assets/icon.png", "userInterfaceStyle": "light", "splash": { "image": "./assets/splash.png", "resizeMode": "contain", "backgroundColor": "#ffffff" }, "assetBundlePatterns": ["**/*"], "ios": { "supportsTablet": true, "bundleIdentifier": "com.jsummers1329.HalfBaked1", "infoPlist": { "CFBundleURLTypes": [ { "CFBundleURLSchemes": ["myapp"] } ] } }, "android": { "adaptiveIcon": { "foregroundImage": "./assets/adaptive-icon.png", "backgroundColor": "#ffffff" }, "package": "com.jsummers1329.HalfBaked1", "intentFilters": [ { "action": "VIEW", "data": [ { "scheme": "https", "host": "dev-wf6hagbsmen8xmma.us.auth0.com", "pathPrefix": "/android/com.jsummers1329.HalfBaked1/callback" } ], "category": ["BROWSABLE", "DEFAULT"] } ] }, "web": { "favicon": "./assets/favicon.png" }, "extra": { "eas": { "projectId": "ddf6f986-e5ae-4f81-b552-a260844b2706" }, "auth0Domain": "dev-wf6hagbsmen8xmma.us.auth0.com", "auth0Scheme": "myapp" } } }
解决方案
错误根源是AndroidManifest中的<auth0Domain>和<auth0Scheme>占位符没有被正确赋值。虽然在expo.extra中定义了这两个变量,但Expo托管工作流不会自动将extra中的变量映射到Android的Manifest占位符,必须在android.manifestPlaceholders字段中明确配置。
修改app.json的android字段,添加manifestPlaceholders配置:
"android": { "adaptiveIcon": { "foregroundImage": "./assets/adaptive-icon.png", "backgroundColor": "#ffffff" }, "package": "com.jsummers1329.HalfBaked1", "intentFilters": [ { "action": "VIEW", "data": [ { "scheme": "https", "host": "dev-wf6hagbsmen8xmma.us.auth0.com", "pathPrefix": "/android/com.jsummers1329.HalfBaked1/callback" } ], "category": ["BROWSABLE", "DEFAULT"] } ], "manifestPlaceholders": { "auth0Domain": "dev-wf6hagbsmen8xmma.us.auth0.com", "auth0Scheme": "myapp" } }
配置完成后重新触发EAS构建,Gradle会在构建过程中自动替换Manifest中的占位符,解决当前的构建失败问题。
内容的提问来源于stack exchange,提问作者Joseph
相关产品推荐
相关产品推荐

