flutter 浏览次数:1554次:1554次错误:找不到符号

gcuhipw9  于 2022-11-17  发布在  Flutter
关注(0)|答案(3)|浏览(126)

我有flutter应用程序脚本,这是购买从代码峡谷。编译后,它android手机,我得到这个错误在我的手机。
如果是android 33错误,然后让我知道

launching lib/main.dart on RMX2020 in debug mode...
    Running Gradle task 'assembleDebug'...
    Warning: The plugin flutter_local_notifications requires Android SDK version 33.
    For more information about build configuration, see https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
    One or more plugins require a higher Android SDK version.
    Fix this issue by adding the following to /Users/apple/Downloads/stackfood/User app and web/android/app/build.gradle:
    android {
      compileSdkVersion 31
      ...
    }
    
    Note: Some input files use or override a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    Note: Some input files use unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    /Users/apple/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_local_notifications-9.9.1/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java:1554: error: cannot find symbol
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
                                                        ^
      symbol:   variable TIRAMISU
      location: class VERSION_CODES
    /Users/apple/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_local_notifications-9.9.1/android/src/main/java/com/dexterous/flutterlocalnotifications/FlutterLocalNotificationsPlugin.java:1555: error: cannot find symbol
          String permission = Manifest.permission.POST_NOTIFICATIONS;
                                                 ^
      symbol:   variable POST_NOTIFICATIONS
      location: class permission
    2 errors
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':flutter_local_notifications:compileDebugJavaWithJavac'.
    > Compilation failed; see the compiler error output for details.
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    
    * Get more help at https://help.gradle.org
    
    BUILD FAILED in 1m 11s
    Exception: Gradle task assembleDebug failed with exit code 1


    if (Build.VERSION.SDK_INT >= VERSION_CODES.S)
    {
      String permission = Manifest.permission.POST_NOTIFICATIONS;
      boolean permissionGranted =
          ContextCompat.checkSelfPermission(mainActivity, permission)
              == PackageManager.PERMISSION_GRANTED;

      if (!permissionGranted) {
        permissionRequestInProgress = true;
        ActivityCompat.requestPermissions(
            mainActivity, new String[] {permission}, NOTIFICATION_PERMISSION_REQUEST_CODE);
      } else {
        this.callback.complete(true);
        permissionRequestInProgress = false;
      }
    }

    else {
      NotificationManagerCompat notificationManager = NotificationManagerCompat.from(mainActivity);
      this.callback.complete(notificationManager.areNotificationsEnabled());
    }
  }
gpfsuwkq

gpfsuwkq1#

从错误消息中单击转到该行。然后
仅注解掉

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {---}

并保留其他部分。现在它将工作正常。问题与最新版本的权限。提拉米苏尚未稳定

ujv3wf0j

ujv3wf0j2#

升级此行android { compileSdkVersion 33
默认配置{

targetSdkVersion 33
xmd2e60i

xmd2e60i3#

升级到sdk 33没有为我工作,因为依赖性限制,一些软件包不支持sdk 33,我已经设置flutter_local_notifications插件到支持sdk 31的最新版本,在文件pubspec.yaml我添加了这个

flutter_local_notifications: 9.7.1

至相依性清单

相关问题