【问题标题】:Cannot invoke method containsKey() on null object无法在空对象上调用方法 containsKey()
【发布时间】:2018-09-14 06:52:01
【问题描述】:

我在通过 gradle 构建我的 Android 项目时遇到了这个错误。它大约每周发生一次。

FAILURE: Build failed with an exception.

* What went wrong:
Failed to capture snapshot of input files for task ':xxxxxxxx:compileDebugAidl' property 'importDirs' during up-to-date check.
> Cannot invoke method containsKey() on null object

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

知道什么可能导致此错误吗?谢谢

【问题讨论】:

  • 请问Try: Run with --stacktrace option to get the stack trace
  • 你的 gradle 插件版本是什么?
  • 或者更好:--scan 在 gradle.properties 的某个地方
  • 我正在使用类路径 'com.android.tools.build:gradle:3.1.4' 我无法正确复制它。这只是随机发生的。
  • issuetracker.google.com/issues/114705291 - 谷歌跟踪器中的相关问题

标签: android android-gradle-plugin google-play-services


【解决方案1】:

从@tapchicoma 对原始问题的评论,问题:NullPointerException in Google Services Plugin 现在标记为已修复4.2.0

所以,最终的解决方案是更新到:

classpath 'com.google.gms:google-services:4.2.0'

【讨论】:

    【解决方案2】:

    在谷歌修复错误之前,降级到播放服务 4.0.1 似乎到目前为止已经为我解决了这个问题:

    classpath 'com.google.gms:google-services:4.0.1'

    https://stackoverflow.com/a/50930048/4096987

    【讨论】:

    • 此问题与@tapchicoma 指出的 issuetracker.google.com/issues/114705291 有关。建议的解决方法是降级到 3.x.x 。
    • @alexfdz 这只是一种意见。就像我提到的那样,我们在我的团队中亲身经历过这个问题,降级到 4.0.1 就足以解决我们的问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多