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

React Native构建报错:groovy.lang.MissingPropertyException(ABI属性缺失)

解决方案

1. 修复build.gradle中的ABI属性访问错误

找到android/app/build.gradle第240行,问题出在错误访问了OutputFile类的abi属性——该类本身不具备这个属性,正确做法是直接从**构建输出变体(output)**对象获取ABI信息,而非输出文件(outputFile)。

举个修正示例:

  • 错误写法(触发异常):
    def abi = output.outputFile.abi
    
  • 修正后写法:
    def abi = output.abi
    

如果你的代码是用于处理ABI拆分或自定义输出文件名,确保所有涉及ABI的逻辑都直接从output对象获取。

2. 解决Gradle版本兼容性问题

运行gradlew --warning-mode all查看具体弃用警告,然后调整Gradle与Android Gradle Plugin(AGP)版本,确保两者匹配:

  • 打开android/build.gradle,找到dependencies块中的AGP版本:
    classpath "com.android.tools.build:gradle:7.3.1" // 示例版本
    
  • 打开android/gradle/wrapper/gradle-wrapper.properties,修改Gradle版本与AGP对应(比如AGP 7.3.1对应Gradle 7.5):
    distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
    
    React Native项目建议直接使用官方文档推荐的版本组合,避免兼容性冲突。

3. 清理并重新构建

执行以下命令清理缓存后重新构建:

gradlew clean
gradlew app:installDebug -PreactNativeDevServerPort=8081

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.04 02:40:25