无法在我的应用程序的 java 文件夹中创建 Application.java 文件

can't create Application.java file inside java folder of my app

我正在 vscode 上开发一个 flutter 应用程序,并尝试将设备到设备的通知功能添加到我的应用程序。 我遵循了视频指南- Device to Device Notification | FCM | Firebase and Flutter , 但我没有收到任何通知。所以我认为这是因为我在 android/app/main/java/ 中创建 Application.java 文件时遇到错误。错误是 Application.java is not on the classpath of project app. Only syntax errors are reported. 我试图在 android 工作室中打开 vscode android 文件来创建 Application.java 文件,但不知何故 vscode 说 can't find android studio.

  1. 如何创建 Application.java 文件而不出现任何错误?
  2. 如果无法正确创建 Application.java 文件,如何使设备到设备的通知工作?

截图;

  1. 我的应用文件夹结构https://i.stack.imgur.com/wTXil.png
  2. 我的Application.java文件位置https://i.stack.imgur.com/qeJDs.png
  3. 错误 Application.java https://i.stack.imgur.com/0TCT2.png

请查看此 github 问题:not on the classpath of project app, only syntax errors are reported

制作组开发者回复android is not supported by VSCode-Java并说明:

Android uses special Gradle plugins to compute the project classpath, that are not supported in Buildship, the underlying Gradle Integration plugin we delegate Gradle support to.

Currently, there is no ideal solution for that but you can try the Lightweight mode by settingjava.server.launchMode to LightWeight. You will be able to use a subset of features like Go to Definition of the types inside your local source and JDK. But there are also limitations, you won't be able to navigate to the types in Android SDK, and you won't be able to build and debug.