Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Crash: Permission Denial: ... requires null, or grantUriPermission() #971

Closed
1 of 2 tasks
tkas9mbek opened this issue Dec 29, 2022 · 6 comments
Closed
1 of 2 tasks
Labels
platform: android Issue is related to the Android platform. status: closed (missing info) Indicates the issue was automatically closed due to a lack of information. status: needs more info We need more information before we can continue work on this issue. type: bug Something isn't working

Comments

@tkas9mbek
Copy link

tkas9mbek commented Dec 29, 2022

🐛 Bug Report

Firebase Crashlytics reports the following crash:

Fatal Exception: java.lang.RuntimeException: An error occurred while executing doInBackground()
       at android.os.AsyncTask$4.done(AsyncTask.java:399)
       at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
       at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
       at java.util.concurrent.FutureTask.run(FutureTask.java:271)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
       at java.lang.Thread.run(Thread.java:919)
Caused by java.lang.SecurityException: Permission Denial: reading com.android.providers.contacts.ContactsProvider2 uri content://com.android.contacts/data from pid=3296, uid=10475 requires null, or grantUriPermission()
       at android.os.Parcel.createException(Parcel.java:2074)
       at android.os.Parcel.readException(Parcel.java:2042)
       at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:188)
       at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:140)
       at android.content.ContentProviderProxy.query(ContentProviderProxy.java:423)
       at android.content.ContentResolver.query(ContentResolver.java:946)
       at android.content.ContentResolver.query(ContentResolver.java:881)
       at android.content.ContentResolver.query(ContentResolver.java:837)
       at flutter.plugins.contactsservice.contactsservice.ContactsServicePlugin.getCursor(ContactsServicePlugin.java:521)
       at flutter.plugins.contactsservice.contactsservice.ContactsServicePlugin.access$500(ContactsServicePlugin.java:55)
       at flutter.plugins.contactsservice.contactsservice.ContactsServicePlugin$GetContactsTask.doInBackground(ContactsServicePlugin.java:451)
       at flutter.plugins.contactsservice.contactsservice.ContactsServicePlugin$GetContactsTask.doInBackground(ContactsServicePlugin.java:427)
       at android.os.AsyncTask$3.call(AsyncTask.java:378)
       at java.util.concurrent.FutureTask.run(FutureTask.java:266)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
       at java.lang.Thread.run(Thread.java:919)

We are getting about 200 crash events monthly on different devices and Android versions (with over 500K monthly users). The crash is related to the denial of permission for the user's contacts. Generally, when such an exception is thrown, it tells you what permission is missing, such as requires android.permission.READ_CONTACTS or android.permission.WRITE_CONTACTS. But in our case, it says that requires null, or grantUriPermission().

Our application only reads the user's contacts, so we have <uses-permission android:name="android.permission.READ_CONTACTS" /> in the AndroidManifest.

We tried to reproduce the issue, but couldn't.

Configuration

[√] Flutter (Channel stable, 3.0.5, on Microsoft Windows [Version 10.0.19044.1889], locale ru-RU)
    • Flutter version 3.0.5 at C:\tools\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f1875d570e (6 months ago), 2022-07-13 11:24:16 -0700
    • Engine revision e85ea0e79c
    • Dart version 2.17.6
    • DevTools version 2.12.2

[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at C:\Users\k_tashbaev\AppData\Local\Android\sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[√] Chrome - develop for the web
    • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

[X] Visual Studio - develop for Windows
    X Visual Studio not installed; this is necessary for Windows development.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components

[√] Android Studio (version 2021.3)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin can be installed from:
       https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
       https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[√] VS Code (version 1.73.1)
    • VS Code at C:\Users\k_tashbaev\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension can be installed from:
[√] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.19044.1889]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 108.0.5359.125
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 92.0.902.67

[√] HTTP Host Availability
    • All required HTTP hosts are available

Version: 10.2.0

Platform:

  • 📱 iOS
  • 🤖 Android
@marcoviz
Copy link

marcoviz commented Jan 2, 2023

Same here

@pritish-thub
Copy link

This might help https://www.youtube.com/watch?v=uMvGpBOT0ZY

@lan2000
Copy link

lan2000 commented May 23, 2023

permission_handler: 10.2.0

AndroidManifest.xml
The following code has been added:

  <uses-permission android:name="android.permission.READ_CONTACTS" />
   <uses-permission android:name="android.permission.WRITE_CONTACTS" />

The following code has an exception.
var status = await Permission.contacts.status;

I get:

FATAL EXCEPTION: pool-1-thread-1
Process: com.example.untitled54, PID: 21454
java.lang.RuntimeException: An error occurred while executing doInBackground()
	at android.os.AsyncTask$AsyncFutureTask.done(AsyncTask.java:429)
	at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
	at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
	at java.util.concurrent.FutureTask.run(FutureTask.java:271)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
	at java.lang.Thread.run(Thread.java:929)
Caused by: java.lang.SecurityException: Permission Denial: opening provider com.android.providers.contacts.ContactsProvider2 from ProcessRecord{2050105 21454:com.example.untitled54/u0a709} (pid=21454, uid=10709) requires android.permission.READ_CONTACTS or android.permission.WRITE_CONTACTS
	at android.os.Parcel.createException(Parcel.java:2090)
	at android.os.Parcel.readException(Parcel.java:2058)
	at android.os.Parcel.readException(Parcel.java:2006)
	at android.app.IActivityManager$Stub$Proxy.getContentProvider(IActivityManager.java:5268)
	at android.app.ActivityThread.acquireProvider(ActivityThread.java:7742)
	at android.app.ContextImpl$ApplicationContentResolver.acquireUnstableProvider(ContextImpl.java:2981)
	at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:2174)
	at android.content.ContentResolver.query(ContentResolver.java:939)
	at android.content.ContentResolver.query(ContentResolver.java:891)
	at android.content.ContentResolver.query(ContentResolver.java:840)
	at flutter.plugins.contactsservice.contactsservice.ContactsServicePlugin.getCursor(ContactsServicePlugin.java:521)
	at flutter.plugins.contactsservice.contactsservice.ContactsServicePlugin.access$500(ContactsServicePlugin.java:55)
	at flutter.plugins.contactsservice.contactsservice.ContactsServicePlugin$GetContactsTask.doInBackground(ContactsServicePlugin.java:451)
	at flutter.plugins.contactsservice.contactsservice.ContactsServicePlugin$GetContactsTask.doInBackground(ContactsServicePlugin.java:427)
	at android.os.AsyncTask$3.call(AsyncTask.java:389)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	... 3 more
Caused by: android.os.RemoteException: Remote stack trace:
	at com.android.server.am.ActivityManagerService.getContentProviderImpl(libmapleservices.so:6748968)
	at com.android.server.am.ActivityManagerService.getContentProvider(libmapleservices.so:6765912)
	at android.app.IActivityManager$Stub.onTransact(libmapleframework.so:6177812)
	at com.android.server.am.ActivityManagerService.onTransact(libmapleservices.so:7783640)
	at com.android.server.am.HwActivityManagerService.onTransact(libmaplehwServices.so:2475508)
callee: null 1580/2164

I/Process (21454): Sending signal. PID: 21454 SIG: 9
Lost connection to device.

Configuration
compileSdkVersion 33
targetSdkVersion 33

 Flutter (Channel stable, 3.7.12, on Microsoft Windows [版本 10.0.19042.630], locale zh-CN)
    • Flutter version 3.7.12 on channel stable at D:\flutter\flutter
    • Upstream repository https://github.com/flutter/flutter/
    • FLUTTER_GIT_URL = https://github.com/flutter/flutter/
    • Framework revision 4d9e56e694 (5 weeks ago), 2023-04-17 21:47:46 -0400
    • Engine revision 1a65d409c7
    • Dart version 2.19.6
    • DevTools version 2.20.1

 Connected device (4 available)
    • WLZ AL10 (mobile) • FMLDU19C13016286 • android-arm64  • Android 10 (API 29)

@JeroenWeener JeroenWeener added platform: android Issue is related to the Android platform. type: bug Something isn't working labels Jun 30, 2023
@JeroenWeener
Copy link
Contributor

Hi @tkas9mbek, thank you for reporting this issue!

I see that the error originates from the contacts_service plugin. Have you checked if the problem is with the permission_handler or with this plugin instead? I could help looking into it, but for that I would need a code sample.

@JeroenWeener JeroenWeener added the status: needs more info We need more information before we can continue work on this issue. label Jun 30, 2023
@github-actions
Copy link

Without additional information, we are unfortunately not able to resolve this issue. Therefore, we reluctantly closed this issue for now. If you run into this issue later, feel free to file a new issue with a reference to this issue. Add a description of detailed steps to reproduce, expected and current behaviour, logs and the output of 'flutter doctor -v'. Thanks for your contribution.

@github-actions github-actions bot added the status: closed (missing info) Indicates the issue was automatically closed due to a lack of information. label Jul 17, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jul 17, 2023
@hayatshin
Copy link

I encounter same issue here during background work with package contacts_service. please resolve this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: android Issue is related to the Android platform. status: closed (missing info) Indicates the issue was automatically closed due to a lack of information. status: needs more info We need more information before we can continue work on this issue. type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants