Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[Bug]: Missing permissions required by NotificationManagerCompat.notify #1393

Open
3 of 8 tasks
Huber1 opened this issue Dec 6, 2023 · 12 comments
Open
3 of 8 tasks

Comments

@Huber1
Copy link

Huber1 commented Dec 6, 2023

Please check the following before submitting a new issue.

Please select affected platform(s)

  • 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.

@TimHoogstrate
Copy link
Contributor

Dear @Huber1,

Do you still have this issue? I cannot reproduce this.

Kind regards,

Tim

@TimHoogstrate TimHoogstrate added the status: needs more info We need more information before we can continue work on this issue. label Jan 4, 2024
@Huber1
Copy link
Author

Huber1 commented Jan 4, 2024

Hi Tim,
I am currently on vacation so I can tell you next week.
Thanks for your work on this package

@github-actions github-actions bot removed the status: needs more info We need more information before we can continue work on this issue. label Jan 4, 2024
@Huber1
Copy link
Author

Huber1 commented Jan 13, 2024

I'll close this for now, don't get this error ATM.
If I get it again, I'll reopen the issue.
Thanks for your awesome work on this package

@Huber1 Huber1 closed this as completed Jan 13, 2024
@gellsonmesquita
Copy link

Error: Missing permissions required by NotificationManagerCompat.notify: android.permission.POST_NOTIFICATIONS [MissingPermission]
notificationManager.notify(notificationId, builder.build());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Explanation for issues of type "MissingPermission":

@gellsonmesquita
Copy link

how can i solve this ?
the error is same above

@Demented-Elmo
Copy link

Any updates on this? I'm running into the same problem as OP

@CarlosAlvarezdev
Copy link

CarlosAlvarezdev commented Oct 4, 2024

This is not a final solution, but for the moment works to me:
I change the version of gradle to this one: distributionUrl=https://services.gradle.org/distributions/gradle-7.6.1-all.zip

/android/build.gradle --->

ext.kotlin_version = '1.8.0'
dependencies {
        classpath ('com.android.tools.build:gradle:7.4.2')
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0"
    }

// I think this is specific config only for the packages that I'm using

configurations.all {
        resolutionStrategy.eachDependency { details ->
            def requested = details.requested
            
            if (requested.group == "androidx.webkit" && requested.name == "webkit") {
                details.useVersion "1.6.0"
            }
            
            if (requested.group == "androidx.window" && requested.name == "window") {
                details.useVersion "1.0.0"
            }
            if (requested.group == "androidx.window" && requested.name == "window-java") {
                details.useVersion "1.0.0"
            }
            
            if (requested.group == "androidx.fragment" && requested.name == "fragment") {
                details.useVersion "1.6.0"  
            }
            
            if (requested.group == "androidx.lifecycle" && requested.name.startsWith("lifecycle-")) {
                details.useVersion "2.6.0"  
            }
            
            if (requested.group == "androidx.core" && (requested.name == "core" || requested.name == "core-ktx")) {
                details.useVersion "1.8.0"  
            }

            
            if (requested.group == "androidx.annotation" && requested.name == "annotation-experimental") {
                details.useVersion "1.3.0"  
            }

            if (requested.group == "androidx.activity" && requested.name == "activity") {
                details.useVersion "1.7.0"  
            }
        }
    }

/android/app/build.gradle --->

compileSdkVersion 33
minSdkVersion 21
targetSdkVersion 33

/settings.gradle --->

plugins {
    id "dev.flutter.flutter-plugin-loader" version "1.0.0"
    id "com.android.application" version '7.4.2' apply false
    id "org.jetbrains.kotlin.android" version "1.8.0" apply false
}

I hope that works to you, It is a solution in the meantime

@geeksilva97
Copy link

geeksilva97 commented Nov 19, 2024

Can you reopen this issue? I'm facing this issue.

geolocator_android-4.3.1/android/src/main/java/com/baseflow/geolocator/location/BackgroundNotification.java:93: Error: Missing permissions required by NotificationManagerCompat.notify: android.permission.POST_NOTIFICATIONS [MissingPermission]
            notificationManager.notify(notificationId, builder.build());
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Version: geolocator: ^10.1.0

app/build.gradle

buildscript {
    ext.kotlin_version = '1.8.0'
    //Needed for BackgroundFetch Flutter package
    ext {
        compileSdkVersion   = 34                // or higher
        targetSdkVersion    = 34                // or higher
        appCompatVersion    = "1.1.0"           // or higher
    }
    //
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.2.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        // Add the google services classpath
        classpath 'com.google.gms:google-services:4.3.15'
        //Crashlytics
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.9'

    }
}

allprojects {
    repositories {
        google()
        jcenter()
        flatDir {
            dirs 'libs'
        }
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
    project.evaluationDependsOn(':app')
}

tasks.register("clean", Delete) {
    delete rootProject.buildDir
}

@damianr13
Copy link

I am also facing this issue in version 4.6.1

@vorn-dev-ni
Copy link

same issue

@MyBlueford16
Copy link

MyBlueford16 commented Feb 12, 2025

@TimHoogstrate
I'm having this same issue as well and it seems others still are also, can this be reopened?

I believe this PR fixes it.. can you merge it in??
#1593

@Huber1 Huber1 reopened this Feb 12, 2025
@Huber1
Copy link
Author

Huber1 commented Feb 12, 2025

i reopened this now, because others still have the problem

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants