简体   繁体   English

@NonNull的提示无法通过按ALT + ENTER键起作用

[英]Hint for @NonNull not working by pressing ALT+ENTER

I am getting problem in shortcut of Auto Insert code: ALT + ENTER 我在自动插入代码的快捷方式中遇到问题: ALT + ENTER

Not annotated parameter overrides @ParametersAreNonnullByDefault 未注释的参数会覆盖@ParametersAreNonnullByDefault

Inspection info: This inspection reports problems related to @Nullable and @NotNull annotations usage configured in Constant conditions & exceptions inspection. 检查信息:此检查报告与在“恒定条件和异常”检查中配置的@Nullable和@NotNull批注使用相关的问题。

I know that by pressing ALT + ENTER we are getting option as below: 我知道通过按ALT + ENTER,我们得到如下选项:

在此输入图像描述

And It will annotate automatically by press ENTER . 然后按ENTER自动注释。

But I am getting following options (There is no option to annotate directly) 但是我得到以下选项(没有选项可以直接注释)

在此输入图像描述

Why the above image not showing option to Annotate directly. 为什么上面的图片没有显示直接Annotate选项。

I am using Android Studio: 我正在使用Android Studio:

Android Studio 3.3.2
Build #AI-182.5107.16.33.5314842, built on February 16, 2019
JRE: 1.8.0_152-release-1248-b01 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.18.0-16-generic

Issue: 问题:

I have one project in PC-1 named "UserApp" created using Android Studio 3.3.1, Another Project "DriverApp" in PC-2 created using same version. 我在PC-1中使用Android Studio 3.3.1创建了一个名为“ UserApp”的项目,在PC-2中使用相同版本创建了一个名为“ DriverApp”的项目。

This annotation problems come up with both project but In "UserApp" its solved by updating Android Studio 3.3.2 这两个项目都出现了注释问题,但是在“ UserApp”中通过更新Android Studio 3.3.2解决了

Now I am coping "DriverApp" in PC-1 but and compiling in Android Studio 3.3.2 but getting same error as previously I got. 现在,我在PC-1中处理“ DriverApp”,但在Android Studio 3.3.2中进行编译,但得到的错误与以前的错误相同。

How can I rebuild "DriverApp" project so I get that annotation working? 如何重建“ DriverApp”项目,以使该注释正常工作?

I have tried: 我努力了:

  • Restart, Invalidate cache, and Restart 重新启动,使缓存无效并重新启动
  • Build Project 建设项目
  • Clean Project 清洁项目

Settings > Build, Execution, Deployment > Compiler > Annotation Processors. 设置>构建,执行,部署>编译器>注释处理器。 Tick 'Enable annotation processing'. 勾选“启用注释处理”。 在此输入图像描述

I found answer as I have implemented following steps: 我已经执行以下步骤,因此找到了答案:

  • After pressing ALT + ENTER , Click on right arrow of "Inspection '@NotNull/@Nullable problems'" and then Run inspection on... ALT + ENTER后 ,单击“检查'@ NotNull / @ Nullable问题'的向右箭头,然后Run inspection on...

You will be prompted for Scope of Inspection. 系统将提示您输入检查范围。 That should be Whole Project . 那应该是Whole Project

在此输入图像描述

In that you will came to know how many places need to change. 这样一来,您将知道需要更改多少个位置。 By clicking on "AndroidX Annotation", It will use annotation for AndroidX. 通过单击“ AndroidX注释”,它将为AndroidX使用注释。

This problem occurred after Migration of AndroidX. 迁移AndroidX后发生此问题

Hope it will helps you. 希望对您有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 快捷键 alt+enter 在 Android Studio 中不起作用 - Shortcut alt+enter is not working in Android Studio 在android Studio Alt + Enter或Control + I for Implementation中无效 - In android Studio Alt+Enter or Control+I for Implementation is not working 使用 alt+enter 导入类后出错 - Error after importing class using alt+enter Android Studio Alt +输入自动导入设置 - Android Studio Alt+Enter auto import settings Android-Studio:Alt + Enter后如何启用“为参数创建字段” - Android-Studio: How to enable “Create field for parameter” after Alt+Enter 使用 Android Studio 中的“Alt+Enter”快捷方式,“删除小部件”选项对于 Flutter 不可用 - 'Remove widget' option unavailable for Flutter using 'Alt+Enter' shortcut in Android Studio 如何在IntelliJ / Android Studio中更改Alt + Enter键盘快捷键? - How do I change Alt+Enter keyboard shortcut in IntelliJ/Android Studio? Android Studio alt + enter 不适用于 flutter - Android Studio alt + enter not working for flutter 基本问题:Alt + Enter 快捷方式对我不起作用 - Basic question : Alt + Enter shortcut not working for me 当我试图调用它时,无法在 Android Studio 中解析按钮 class。 Alt+Enter 或 Ctrl+Space 无法解决问题。 有任何想法吗? - I can't resolve the Button class in Android Studio when I tried to call it. Alt+Enter or Ctrl+Space doesn't resolve it. Any ideas?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM