Android Studio 如何显示 "Parcelable implementation needs CREATOR field" 的错误?

How does Android Studio show Error of "Parcelable implementation needs CREATOR field"?

我了解有必要在 Parcelable 的 class 中实施 Parcelable.Creator。

但我不明白如果我没有实现 Parcelable.Creator 接口,编辑器是如何知道并显示错误的。

"This class implements parcelable but does not provide a CREATOR field"

即使在 Android Studio 中显示错误,我仍然可以成功构建应用程序。

看来其实不是编译错误而是提示?

我想知道它是通过什么方式检测和提醒程序员的。

非常感谢。

Android studio 使用 Lint 扫描代码并提出改进或更改建议。

https://developer.android.com/studio/write/lint.html

那是提示警告的lint tool。您可以在 Preferences -> Editor -> Inspections -> Android -> Lint 菜单中查看规则列表。

您也可以通过 lint 禁用您不想成为的规则运行。