【问题标题】:Build Gradle Error Could not get unknown property 'compile'构建 Gradle 错误无法获取未知属性“编译”
【发布时间】:2021-11-01 18:08:03
【问题描述】:

我在运行 android 时对原生项目做出反应,显示此错误

构建文件 'C:\dev\icnet_final\android\app\build.gradle' 行:213

评估项目 ':app' 时出现问题。

无法为 org.gradle.api.internal.artifacts.configurations.DefaultConfigurationContainer 类型的配置容器获取未知属性“编译”。

【问题讨论】:

    标签: android react-native gradle


    【解决方案1】:

    如果在 Gradle 升级后发生这种情况,请将 compile 替换为 implementation

    【讨论】:

    • 注意,对于有BUCK配置的线路也必须这样做,即将configurations.compile改为configurations.implementation
    • 这确实为我清除了特定错误,但我在 java 版本中遇到了后续问题。我最终使用了disconnectionist's answer - 从4.2.1 升级到7.0.3 我只升级到4.2.2
    • 它应该是runtimeClasspath 而不是implementation
    • 关于configurations.implementation: Resolving dependency configuration 'implementation' is not allowed as it is defined as 'canBeResolved=false'.
    【解决方案2】:

    我收到此错误是因为我升级到最新版本的 Gradle。我建议不要这样做,直到 React Native 更新到可以使用它。

    我将 android/build.gradle 中的 Gradle 版本更改为旧版本,并再次构建项目。这个版本现在适用于我:

        classpath('com.android.tools.build:gradle:4.2.2')
    

    【讨论】:

    • 拯救了我的一天..这应该是最被接受的答案
    • 所以从 gradle 7 降级到 4 是一个可以接受的答案:(
    • @mikegross - 同样在这里,我将我的4.2.1 => 7.0.3 升级降到了4.2.1 => 4.2.2。痛苦少了很多。
    • 经过一夜的挖掘,你救了我的命,谢谢!
    【解决方案3】:

    RN 0.64.1 对于依赖,我使用

        classpath('com.android.tools.build:gradle:7.0.0')
    

    对于包装器

        distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-09-14
      • 1970-01-01
      • 2018-08-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-05
      相关资源
      最近更新 更多