问题

Missing nullability on field miSyncResult in class class android.content.SyncResult [MissingNullability]

分析

1.由于Android的编译检查,导致java类中的属性miSyncResult 被检查出没有设置nullability属性而报错
2. 为了提高代码质量可以根据属性是否可空进行注解.

解决方法示例

	@NonNull  // 不可空
    public final MiSyncResult miSyncResult;

	@Nullable  // 可空
    private String resultMessage;

参考

1.Handling Nullability in Android 11 and Beyond
https://android-developers.googleblog.com/2020/03/handling-nullability-in-android-11-and.html
2.Improve code inspection with annotations
https://developer.android.com/studio/write/annotations#java
3.Spring 中的Null-Safety
https://www.cnblogs.com/cxuanBlog/p/11081002.html

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐