使用EAS构建React Native应用时:expo:compileReleaseKotlin任务失败
React Native EAS构建失败问题解决
使用EAS构建React Native应用时持续失败,环境为Linux(Crostini),已尝试卸载重装Expo CLI、多次构建、检查代码等操作,仍无法解决。报错信息如下:
Task :expo:compileReleaseKotlin FAILED1470 [stderr] e: /home/expo/workingdir/build/node_modules/expo/android/src/main/java/expo/modules/ReactNativeHostWrapperBase.kt: (50, 3): 'getUIImplementationProvider' overrides nothing1471 [stderr] e: /home/expo/workingdir/build/node_modules/expo/android/src/main/java/expo/modules/ReactNativeHostWrapperBase.kt: (50, 76): Unresolved reference: UIImplementationProvider1472 [stderr] e: /home/expo/workingdir/build/node_modules/expo/android/src/main/java/expo/modules/ReactNativeHostWrapperBase.kt: (51, 12): Not enough information to infer type variable T1473> Task :expo-modules-core:buildCMakeRelWithDebInfo[x86_64]1474w: Detected multiple Kotlin daemon sessions at build/kotlin/sessions1475Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.1476You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.1477See https://docs.gradle.org/7.3.3/userguide/command_line_interface.html#sec:command_line_warnings1478Execution optimizations have been disabled for 1 invalid unit(s) of work during this build to ensure correctness.1479Please consult deprecation warnings for more details.1480377 actionable tasks: 377 executed1481 [stderr] FAILURE: Build failed with an exception.1482 [stderr] * What went wrong:1483[stderr] Execution failed for task ':expo:compileReleaseKotlin'.1484[stderr] > A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction1485[stderr] > Compilation error. See log for more details1486 [stderr] * Try:1487[stderr] > Run with --stacktrace option to get the stack trace.1488[stderr] > Run with --info or --debug option to get more log output.1489[stderr] > Run with --scan to get full insights.1490[stderr] * Get more help at https://help.gradle.org1491[stderr] BUILD FAILED in 5m 47s1492Error: Gradle build failed with unknown error. See logs for the "Run gradlew" phase for more information.
解决方案
- 校验Expo与React Native版本兼容性:报错核心是Expo代码中引用的
UIImplementationProvider类在当前React Native版本中不存在或已变更,需确保两者版本处于官方兼容范围内,调整package.json中的expo和react-native版本后重新安装依赖。 - 清除缓存并重建依赖:执行以下命令清理缓存和依赖,再尝试构建:
rm -rf node_modules package-lock.json yarn.lock npm install expo r -c - 统一Gradle版本:在
android/gradle/wrapper/gradle-wrapper.properties中指定与Expo版本匹配的Gradle版本,避免版本不兼容导致的构建问题。 - 同步Expo模块版本:确保所有expo相关依赖(如expo-modules-core)的版本与expo主版本一致,避免跨版本冲突。
内容的提问来源于stack exchange,提问作者Taboka Fanuel Sialumba
相关产品推荐
相关产品推荐

