升级至Gradle 7.3.3后:compileDebugRenderscript任务执行失败求助
Gradle 7.3.3升级后RenderscriptCompile任务配置错误解决建议
错误信息
升级Gradle至7.3.3后,出现以下任务配置错误:
Some problems were found with the configuration of task ':compileDebugRenderscript' (type 'RenderscriptCompile'). - In plugin 'com.android.build.gradle.api.AndroidBasePlugin' type 'com.android.build.gradle.tasks.RenderscriptCompile' method 'useAndroidX()' should not be annotated with: @Input.
对应的异常详情:
* Exception is: org.gradle.internal.execution.WorkValidationException: Some problems were found with the configuration of task ':compileDebugRenderscript' (type 'RenderscriptCompile'). - In plugin 'com.android.build.gradle.api.AndroidBasePlugin' type 'com.android.build.gradle.tasks.RenderscriptCompile' method 'useAndroidX()' should not be annotated with: @Input. Reason: Input/Output annotations are ignored if they are placed on something else than a getter. Possible solutions: 1. Remove the annotations. 2. Rename the method.
解决方法
方法一:移除错误的@Input注解
找到com.android.build.gradle.tasks.RenderscriptCompile类中的useAndroidX()方法,直接删除其上的@Input注解。如果该类来自第三方依赖库,优先检查是否有修复该问题的新版本,升级依赖库即可。
方法二:将方法重命名为Getter格式
若无法移除注解,将useAndroidX()重命名为isUseAndroidX()或getUseAndroidX(),使其符合Gradle对Getter方法的命名规范,这样@Input注解就能被正确识别生效。
额外建议
如果使用官方Android Gradle插件(AGP),需确保AGP版本与Gradle 7.3.3兼容(Gradle 7.3.3对应AGP 7.2.x或7.3.x版本),升级AGP到对应兼容版本,官方大概率已修复该注解配置问题。
内容的提问来源于stack exchange,提问作者prat
相关产品推荐
相关产品推荐

