Expo Android Play Store构建失败,Gradle配置报错求助
Android Play Store构建失败解决思路
核心错误日志
FAILURE: Build completed with 2 failures. 1: Task failed with an exception. ----------- * Where: Build file '/home/expo/workingdir/build/node_modules/expo-application/android/build.gradle' line: 40 * What went wrong: A problem occurred evaluating project ':expo-application'. > Could not set unknown property 'classifier' for task ':expo-application:androidSourcesJar' of type org.gradle.api.tasks.bundling.Jar. ============================================================================== 2: Task failed with an exception. ----------- * Where: Script '/home/expo/workingdir/build/node_modules/expo-modules-core/android/ExpoModulesCorePlugin.gradle' line: 65 * What went wrong: A problem occurred configuring project ':expo'. > Could not get unknown property 'release' for SoftwareComponent container of type org.gradle.api.internal.component.DefaultSoftwareComponentContainer.
解决思路
1. 修复expo-application的classifier属性错误
- 问题根源:Gradle 7.0+ 废弃了
Jar任务的classifier属性,改用archiveClassifier,旧版expo-application未适配该变更。 - 解决方案:
- 优先方案:升级
expo-application到最新兼容版本,新版本已修复该API适配问题。 - 临时修复:直接修改
node_modules/expo-application/android/build.gradle第40行,将classifier = 'sources'替换为archiveClassifier = 'sources'。
- 优先方案:升级
2. 修复expo-modules-core的release组件获取错误
- 问题根源:Gradle 7.0+ 调整了SoftwareComponent容器的结构,旧版
expo-modules-core的组件获取逻辑失效。 - 解决方案:
- 优先方案:升级
expo-modules-core到最新稳定版本,官方已修复该适配问题。 - 检查项目Gradle版本与expo依赖的兼容性:若使用Gradle 7.0+,确保所有expo插件版本均为适配该Gradle版本的版本;若暂时无法升级插件,可尝试降低Gradle版本到6.x系列。
- 优先方案:升级
3. 通用排查步骤
- 执行
./gradlew clean清除构建缓存后重新尝试构建。 - 确保
package.json中所有expo相关依赖版本统一,且与项目使用的Expo SDK版本匹配。 - 若为Expo managed项目,运行
expo upgrade同步所有依赖至兼容版本。
内容的提问来源于stack exchange,提问作者Grim
相关产品推荐
相关产品推荐

