无法在空对象上调用方法 containsKey()

Cannot invoke method containsKey() on null object

我在 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

知道是什么导致了这个错误吗?谢谢

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

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

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

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

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