You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

重置Flutter开发环境后Android构建报错的解决求助

Flutter Android构建报错:找不到Manifest.permission.POST_NOTIFICATIONS等权限符号

问题背景

近期因驱动问题重置了电脑及Flutter开发环境,现在构建Android应用时出现权限相关编译错误。

初始错误日志

C:\Users\cianr\AppData\Local\Pub\Cache\hosted\pub.dev\firebase_messaging-14.7.10\android\src\main\java\io\flutter\plugins\firebase\messaging\FlutterFirebaseMessagingPlugin.java:389: error: cannot find symbol
            .checkSelfPermission(Manifest.permission.POST_NOTIFICATIONS)
                                                    ^
  symbol:   variable POST_NOTIFICATIONS
  location: class permission
C:\Users\cianr\AppData\Local\Pub\Cache\hosted\pub.dev\firebase_messaging-14.7.10\android\src\main\java\io\flutter\plugins\firebase\messaging\FlutterFirebasePermissionManager.java:63: error: cannot find symbol
    permissions.add(Manifest.permission.POST_NOTIFICATIONS);
                                       ^
  symbol:   variable POST_NOTIFICATIONS
  location: class permission

尝试操作及后续错误

  • 通过Git回退到之前可正常运行的分支,错误仍存在
  • 移除firebase_messaging插件及相关代码后,出现新编译错误:
Note: Recompile with -Xlint:deprecation for details.
C:\Users\cianr\AppData\Local\Pub\Cache\hosted\pub.dev\permission_handler_android-12.0.1\android\src\main\java\com\baseflow\permissionhandler\PermissionUtils.java:56: error: cannot find symbol
            case Manifest.permission.BODY_SENSORS_BACKGROUND:
                                    ^
  symbol:   variable BODY_SENSORS_BACKGROUND
  location: class permission
C:\Users\cianr\AppData\Local\Pub\Cache\hosted\pub.dev\permission_handler_android-12.0.1\android\src\main\java\com\baseflow\permissionhandler\PermissionUtils.java:85: error: cannot find symbol
            case Manifest.permission.POST_NOTIFICATIONS:
                                    ^
  symbol:   variable POST_NOTIFICATIONS
  location: class permission

Windows环境搭建步骤

  • 安装Git
  • 下载Android Studio及CLI工具
  • 下载VS Code并启用Flutter、Dart插件
  • 下载Flutter压缩包并解压至C:\src
  • 将Flutter添加至环境变量
  • 下载JDK 17,为系统和用户变量添加JAVA_HOME

Flutter Doctor结果

PS C:\Users\cianr> flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.16.5, on Microsoft Windows [Version 10.0.22631.2861], locale en-ZA)
[✓] Windows Version (Installed version of Windows is version 10 or higher)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Chrome - develop for the web
[!] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.8.3)
    ✗ Visual Studio is missing necessary components. Please re-run the Visual Studio installer for the "Desktop
      development with C++" workload, and include these components:
        MSVC v142 - VS 2019 C++ x64/x86 build tools
         - If there are multiple build tool versions available, install the latest
        C++ CMake tools for Windows
        Windows 10 SDK
[✓] Android Studio (version 2023.1)
[✓] VS Code (version 1.85.1)
[✓] Connected device (3 available)
[✓] Network resources

! Doctor found issues in 1 category.
PS C:\Users\cianr>

内容的提问来源于stack exchange,提问作者Cian Robertson

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.02 17:56:32