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

升级Gradle版本后项目构建失败:ApolloIRGenTask配置异常

Gradle升级至7.3.1后构建失败:ApolloIRGenTask配置错误

错误信息

FAILURE: Build failed with an exception.

* What went wrong:
Some problems were found with the configuration of task ':app:generateDebugApolloIR' (type 'ApolloIRGenTask').
  - In plugin 'com.amazonaws.appsync' type 'com.apollographql.apollo.gradle.ApolloIRGenTask' field 'extension' without corresponding getter has been annotated with @Internal.
    
    Reason: Annotations on fields are only used if there's a corresponding getter for the field.

已尝试操作

  • 重建项目
  • 清理项目
  • 清除Gradle缓存

当前配置

项目级build.gradle

dependencies {
    classpath 'com.android.tools.build:gradle:7.3.1'
    classpath 'com.google.gms:google-services:4.3.14'
    classpath 'com.google.ar.sceneform:plugin:1.17.1'
    classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.2'
    classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10'
    classpath 'com.amplifyframework:amplify-tools-gradle-plugin:1.0.1'
    classpath "com.amazonaws:aws-android-sdk-appsync-gradle-plugin:3.1.0"

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

应用级build.gradle

//AWS
implementation 'com.amplifyframework:core:1.29.0' //updated
implementation 'com.amplifyframework:aws-api:1.28.3' //updated
implementation 'com.amplifyframework:aws-datastore:1.28.3' //updated
implementation 'com.amazonaws:aws-android-sdk-appsync:3.1.1' //updated 
implementation 'com.amazonaws:aws-android-sdk-s3:2.35.0' //updated 

解决方案

方案1:升级AWS AppSync插件及依赖版本

Gradle 7.x对任务注解的使用规范有更严格校验,你当前使用的aws-android-sdk-appsync-gradle-plugin:3.1.0未适配该规范,需升级到兼容版本:

  1. 修改项目级build.gradle的插件版本:
classpath "com.amazonaws:aws-android-sdk-appsync-gradle-plugin:3.3.2" // 替换为最新兼容版本
  1. 同步应用级build.gradle的依赖版本,保持与插件一致:
implementation 'com.amazonaws:aws-android-sdk-appsync:3.3.2'
  1. 同步项目后重新构建。

方案2:切换为Amplify官方集成(推荐)

你已在使用Amplify框架,其aws-api模块已封装AppSync功能,无需额外引入旧版AppSync插件和依赖,可避免版本冲突:

  1. 删除项目级build.gradle中的旧AppSync插件:
// 移除该行:classpath "com.amazonaws:aws-android-sdk-appsync-gradle-plugin:3.1.0"
  1. 删除应用级build.gradle中的旧AppSync依赖:
// 移除该行:implementation 'com.amazonaws:aws-android-sdk-appsync:3.1.1'
  1. 统一Amplify相关依赖版本,避免版本不一致问题:
implementation 'com.amplifyframework:core:1.29.0'
implementation 'com.amplifyframework:aws-api:1.29.0'
implementation 'com.amplifyframework:aws-datastore:1.29.0'
  1. 同步项目后重新构建。

内容的提问来源于stack exchange,提问作者Muhammad Kashif Ahmad

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.15 16:01:08