You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Android 13 requires runtime POST_NOTIFICATIONS permission for DownloadService notifications #10884
I'm not sure if it's the right thing to do to add this permission to a manifest of the library that then is automatically merged into an app manifest. Not every app may use the DownloadService.
I think an app that includes the DownloadService wants to add this permission, but I also think it should be left to the app to do that.
I agree though that we should add this permission to the AndroidManifest.xml of the main demo app as an example to do the right thing. Is this what you are asking for?
It was an open question whether a comment should be added to the abstract class DownloadService in order to specify that if the permission is not asked for A13+ it won't prompt the notification.
I agree that handling the permission should fall upon the app using `DownloadService, also yes the demo might need an update regarding this permission.
Ok, makes sense. Currently the main demo app does never show a notification when downloading (when on targetSdkVersion 33). On API 33 it not only requires the permission to be added to the manifest, but instead the permission also needs to be requested at runtime. Aside: The session demo app is not affected by this change because its notification is exempted because it is attached to a media session.
I think we need to do the following things:
Document in DownloadService that an app with targetSdkVersion 33+ needs to add the android.permission.POST_NOTIFICATIONS to the manifest.
Document that such an app also needs to request Manifest.permission.POST_NOTIFICATIONS at runtime in order to notification to be shown. It's at the app's discretion when to do this, like when the app starts or when a download is triggered.
changed the title [-]Android 13 POST_NOTIFICATIONS[/-][+]Android 13 requires runtime POST_NOTIFICATIONS permission for DownloadService notifications[/+]on Jan 9, 2023
I am in the process of updating to Android Gradle Plugin 7.4. The project I am working on does use ExoPlayer but it does not use DownloadService. However, there appears to be a new lint rule added in Android Gradle Plugin 7.4 that is failing for us due to our dependency on ExoPlayer:
Error: /*****/app/src/main/AndroidManifest.xml: Error: When targeting Android 13 or higher, posting a permission requires holding the POST_NOTIFICATIONS permission (usage from com.google.android.exoplayer2.offline.DownloadService.ForegroundNotificationUpdater) [NotificationPermission]
It feels odd to me to have to specify this permission in the app's manifest if the app does not use DownloadService at all. We could suppress the lint violation for now but that also seems a little odd to me. 🤷♂️
Thanks for reporting. I can repro this. Looks like the linter is a bit aggressive. Not sure what we can do. I filed a bug internally (internal bug-ref: b/271249297).
Repro steps
Download AS Electric Eel.
Create a new project.
Choose 'File - Project structure' and use AGP 7.4 (or greater)
> Task :app:lintReportDebug
Wrote HTML report to file:///usr/local/google/home/bachinger/StudioProjects/MyApplication/app/build/reports/lint-results-debug.html
> Task :app:lintDebug FAILED
Lint found 1 errors, 4 warnings. First failure:
/usr/local/google/home/bachinger/StudioProjects/MyApplication/app/src/main/AndroidManifest.xml: Error: When targeting Android 13 or higher, posting a permission requires holding the POST_NOTIFICATIONS permission (usage from com.google.android.exoplayer2.offline.DownloadService.ForegroundNotificationUpdater) [NotificationPermission]
Explanation for issues of type "NotificationPermission":
When targeting Android 13 and higher, posting permissions requires holding
the runtime permission android.permission.POST_NOTIFICATIONS.
The full lint text report is located at:
/usr/local/google/home/bachinger/StudioProjects/MyApplication/app/build/intermediates/lint_intermediate_text_report/debug/lint-results-debug.txt
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app: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:
/usr/local/google/home/bachinger/StudioProjects/MyApplication/app/src/main/AndroidManifest.xml: Error: When targeting Android 13 or higher, posting a permission requires holding the POST_NOTIFICATIONS permission (usage from com.google.android.exoplayer2.offline.DownloadService.ForegroundNotificationUpdater) [NotificationPermission]
Explanation for issues of type "NotificationPermission":
When targeting Android 13 and higher, posting permissions requires holding
the runtime permission android.permission.POST_NOTIFICATIONS.
The full lint text report is located at:
/usr/local/google/home/bachinger/StudioProjects/MyApplication/app/build/intermediates/lint_intermediate_text_report/debug/lint-results-debug.txt
Reacted by Kai Bernhard, Achraf, Marcelo Hernandez, Dawid Witkowski and Abraham Armas Cordero
Activity
marcbaechinger commentedon Jan 3, 2023
I'm not sure if it's the right thing to do to add this permission to a manifest of the library that then is automatically merged into an app manifest. Not every app may use the
DownloadService.I think an app that includes the
DownloadServicewants to add this permission, but I also think it should be left to the app to do that.I agree though that we should add this permission to the
AndroidManifest.xmlof the main demo app as an example to do the right thing. Is this what you are asking for?yoobi commentedon Jan 3, 2023
It was an open question whether a comment should be added to the
abstract class DownloadServicein order to specify that if the permission is not asked for A13+ it won't prompt the notification.I agree that handling the permission should fall upon the app using `DownloadService, also yes the demo might need an update regarding this permission.
marcbaechinger commentedon Jan 3, 2023
Ok, makes sense. Currently the main demo app does never show a notification when downloading (when on targetSdkVersion 33). On API 33 it not only requires the permission to be added to the manifest, but instead the permission also needs to be requested at runtime. Aside: The session demo app is not affected by this change because its notification is exempted because it is attached to a media session.
I think we need to do the following things:
DownloadServicethat an app with targetSdkVersion 33+ needs to add theandroid.permission.POST_NOTIFICATIONSto the manifest.Manifest.permission.POST_NOTIFICATIONSat runtime in order to notification to be shown. It's at the app's discretion when to do this, like when the app starts or when a download is triggered.marcbaechinger commentedon Jan 3, 2023
Marking this issue as a bug (in the main demo app) on API 33.
[-]Android 13 POST_NOTIFICATIONS[/-][+]Android 13 requires runtime POST_NOTIFICATIONS permission for DownloadService notifications[/+]Request notification permission in demo app for API 33+
Document that `DownloadService` needs notification permissions
Request notification permission in demo app for API 33+
Document that `DownloadService` needs notification permissions
Request notification permission in demo app for API 33+
Document that `DownloadService` needs notification permissions
mhernand40 commentedon Feb 28, 2023
I am in the process of updating to Android Gradle Plugin 7.4. The project I am working on does use ExoPlayer but it does not use
DownloadService. However, there appears to be a new lint rule added in Android Gradle Plugin 7.4 that is failing for us due to our dependency on ExoPlayer:It feels odd to me to have to specify this permission in the app's manifest if the app does not use
DownloadServiceat all. We could suppress the lint violation for now but that also seems a little odd to me. 🤷♂️Here is a similar/related comment:
digitalservicebund/useid-app-android#132 (comment)
marcbaechinger commentedon Mar 1, 2023
Thanks for reporting. I can repro this. Looks like the linter is a bit aggressive. Not sure what we can do. I filed a bug internally (internal bug-ref: b/271249297).
Repro steps
Observed result
Build fails with error message below
Expected result
App can be built without lint errors.
Impr/doris 1730 migrate exo 2.18.4 (#77)
Chore/migrate media 1.0.2 (#10)
Biplovkumar commentedon Aug 21, 2023
@marcbaechinger IllegalArgumentException: Unknown permission: android.permission.POST_NOTIFICATIONS with below version. Please suggest?
marcbaechinger commentedon Aug 21, 2023
@Biplovkumar
You probably need a bit more context to make this actionable for us.
Best is if you can repro this with the demo app.
Tell us what you do, the repro steps, the expected result and the observed result.