You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

构建Android APK时expo-in-app-purchases编译任务失败的解决求助

Android APK构建失败:expo-in-app-purchases编译错误

环境版本

  • expo: 51.0.6
  • react-native: 0.74.1
  • expo-in-app-purchases: ^14.5.0

app.json 配置

{ "expo": { "name": "", "slug": "", "version": "1.11.0", "orientation": "portrait", "icon": "./assets/icon.png", "scheme": "", "userInterfaceStyle": "automatic", "splash": { "image": "./assets/splash.png", "resizeMode": "contain", "backgroundColor": "#000" }, "ios": { "supportsTablet": true, "bundleIdentifier": "com.mimsteri.mimsteri" }, "android": { "versionCode": 11, "adaptiveIcon": { "foregroundImage": "./assets/adaptive-icon.png", "backgroundColor": "#ffffff" }, "package": "com.mimsteri.mimsteri" }, "extra": { "eas": { "projectId": "" } }, "plugins": [ [ "expo-build-properties", { "android": { "minSdkVersion": 30 } } ], "expo-font", "expo-localization" ] } }

构建错误日志

FAILURE: Build failed with an exception.

- What went wrong:
Execution failed for task ':expo-in-app-purchases:compileDebugJavaWithJavac'.

> Compilation failed; see the compiler error output for details.

- Try:

> Run with --info option to get more log output.
Run with --scan to get full insights.
BUILD FAILED in 6m 38s
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.6/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
703 actionable tasks: 702 executed, 1 up-to-date
Error: Gradle build failed with unknown error. See logs for the "Run gradlew" phase for more information.

解决方案

1. 获取详细编译日志

当前错误仅提示编译失败,无具体原因。执行以下命令获取完整错误信息:

# EAS构建时
eas build --platform android --profile development --info

# 本地构建时
./gradlew assembleDebug --info

重点查看:expo-in-app-purchases模块的Java编译报错,比如语法问题、依赖冲突或API版本不兼容细节。

2. 重新安装并校验依赖版本

expo 51官方推荐的expo-in-app-purchases版本为14.5.0,和你的配置匹配,但可尝试重新安装依赖:

npm uninstall expo-in-app-purchases
npm install expo-in-app-purchases@14.5.0

或用expo命令修复依赖:

npx expo install --fix

3. 完善Android SDK版本配置

当前仅设置了minSdkVersion,可补充指定compileSdkVersion和targetSdkVersion,确保与expo 51兼容:

"plugins": [
  [
    "expo-build-properties",
    {
      "android": {
        "minSdkVersion": 30,
        "compileSdkVersion": 34,
        "targetSdkVersion": 34
      }
    }
  ],
  "expo-font",
  "expo-localization"
]

更新配置后执行:

npx expo prebuild --clean

4. 强制依赖AndroidX迁移

在android/gradle.properties中添加以下配置,解决旧依赖与AndroidX的兼容性问题:

android.enableJetifier=true

5. 清理构建缓存

  • 本地构建清理Gradle缓存:
./gradlew clean
  • EAS构建清理缓存:
eas build --platform android --clear-cache

内容的提问来源于stack exchange,提问作者Khvicha Parsadanshvili

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.23 17:47:22