flutter-geolocator icon indicating copy to clipboard operation
flutter-geolocator copied to clipboard

[Bug]: Missing permissions required by NotificationManagerCompat.notify

Open Huber1 opened this issue 1 year ago • 18 comments

Please check the following before submitting a new issue.

Please select affected platform(s)

  • [X] Android
  • [ ] iOS
  • [ ] Linux
  • [ ] macOS
  • [ ] Web
  • [ ] Windows

Steps to reproduce

  1. Go to android directory
  2. Run ./gradlew clean
  3. Run ./gradlew build

Expected results

App builds normally

Actual results

Task :geolocator_android:lintDebug FAILED Lint found 1 errors, 4 warnings. First failure:

/home/moritz/.pub-cache/hosted/pub.dev/geolocator_android-4.4.0/android/src/main/java/com/baseflow/geolocator/location/BackgroundNotification.java:100: Error: Missing permissions required by NotificationManagerCompat.notify: android.permission.POST_NOTIFICATIONS [MissingPermission] notificationManager.notify(notificationId, builder.build()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Explanation for issues of type "MissingPermission": This check scans through your code and libraries and looks at the APIs being used, and checks this against the set of permissions required to access those APIs. If the code using those APIs is called at runtime, then the program will crash.

Furthermore, for permissions that are revocable (with targetSdkVersion 23), client code must also be prepared to handle the calls throwing an exception if the user rejects the request for permission at runtime.

The full lint text report is located at: /home/moritz/IdeaProjects/better_hm/build/geolocator_android/intermediates/lint_intermediate_text_report/debug/lint-results-debug.txt

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':geolocator_android:lintDebug'.
            Lint found errors in the project; aborting build.
              Fix the issues identified by lint, or create a baseline to see only new errors:
              ```
              android {
                  lint {
                      baseline = file("lint-baseline.xml")
                  }
              }
              ```

              For more details, see https://developer.android.com/studio/write/lint#snapshot

              Lint found 1 errors, 4 warnings. First failure:

/home/moritz/.pub-cache/hosted/pub.dev/geolocator_android-4.4.0/android/src/main/java/com/baseflow/geolocator/location/BackgroundNotification.java:100: Error: Missing permissions required by NotificationManagerCompat.notify: android.permission.POST_NOTIFICATIONS [MissingPermission] notificationManager.notify(notificationId, builder.build()); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 Explanation for issues of type "MissingPermission":
 This check scans through your code and libraries and looks at the APIs
 being used, and checks this against the set of permissions required to
 access those APIs. If the code using those APIs is called at runtime, then
 the program will crash.

 Furthermore, for permissions that are revocable (with targetSdkVersion 23),
 client code must also be prepared to handle the calls throwing an exception
 if the user rejects the request for permission at runtime.

The full lint text report is located at: /home/moritz/IdeaProjects/better_hm/build/geolocator_android/intermediates/lint_intermediate_text_report/debug/lint-results-debug.txt


lint-results-debug.txt

Code sample

Not necessary

Screenshots or video

No response

Version

10.1.0 --> geolocator_android: 4.4.0

Flutter Doctor output

[✓] Flutter (Channel stable, 3.16.2, on openSUSE Tumbleweed 6.6.2-1-default, locale en_US.UTF-8) • Flutter version 3.16.2 on channel stable at /usr/local/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 9e1c857886 (6 days ago), 2023-11-30 11:51:18 -0600 • Engine revision cf7a9d0800 • Dart version 3.2.2 • DevTools version 2.28.3

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2) • Android SDK at /home/moritz/Android/Sdk • Platform android-33, build-tools 33.0.2 • Java binary at: /home/moritz/.local/share/JetBrains/Toolbox/apps/android-studio/jbr/bin/java • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314) • All Android licenses accepted.

[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome) ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✓] Linux toolchain - develop for Linux desktop • clang version 17.0.5 • cmake version 3.27.7 • ninja version 1.11.1 • pkg-config version 1.8.0

[✓] Android Studio (version 2023.1) • Android Studio at /home/moritz/.local/share/JetBrains/Toolbox/apps/android-studio • Flutter plugin version 76.3.3 • Dart plugin version 222.4582 • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)

[✓] IntelliJ IDEA Ultimate Edition (version 2023.2) • IntelliJ at /home/moritz/.local/share/JetBrains/Toolbox/apps/intellij-idea-ultimate • Flutter plugin version 76.3.4 • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.84.0) • VS Code at /usr/share/code • Flutter extension can be installed from: 🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (1 available) • Linux (desktop) • linux • linux-x64 • openSUSE Tumbleweed 6.6.2-1-default

[✓] Network resources • All expected network resources are available.

! Doctor found issues in 1 category.

Huber1 avatar Dec 06 '23 17:12 Huber1