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

Permission Denied even after granting the Storage Permission #31122

Closed
krngd2 opened this issue Apr 16, 2019 · 20 comments
Closed

Permission Denied even after granting the Storage Permission #31122

krngd2 opened this issue Apr 16, 2019 · 20 comments

Comments

@krngd2
Copy link

krngd2 commented Apr 16, 2019

My app works with the files i download over the network. I download and save in a folder called "Bizzappv2". After I implement the run time permission request, its stopped working, throwing permission denied error.
When i manually switch on the storage permission from setting its working good, but when I am requesting the permission on run time its showing permission denied error.

On initState I am requesting for the storage permission using the permission plugin

  initPlatformState() async {  
    try {
      await Permission.getPermissionsStatus([PermissionName.Storage]).then((List<Permissions> v){
        print(v[0].permissionStatus);
        if(v[0].permissionStatus == PermissionStatus.deny || v[0].permissionStatus == PermissionStatus.notDecided || v[0].permissionStatus == PermissionStatus.notAgain ){
          Permission.requestPermissions([PermissionName.Storage]).then((d){
            print(d);
          });
        }
      });
     createAndCheckFiles(); //checks if files already exists if not it creates the required folders 
    } on PlatformException {
      print('Failed to get platform version.');
    } 
    if (!mounted) return; 

  }

flutter run --verbose

C:\flutter\bin\cache\dart-sdk\bin\dart
C:\flutter\bin\cache\artifacts\engine\windows-x64\frontend_server.dart.snapshot --sdk-root
C:\flutter\bin\cache\artifacts\engine\common\flutter_patched_sdk/ --incremental --strong --target=flutter
--output-dill build\app.dill --packages F:\Projects\flutter\bizzappv2\.packages --filesystem-scheme org-dartlang-root[ +141 ms] I/flutter (15546): PermissionStatus.notAgain
[ +553 ms] E/flutter (15546): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: FileSystemException:
Creation failed, path = '/storage/emulated/0/bizzapp' (OS Error: Permission denied, errno = 13)
[ +564 ms] E/flutter (15546): #0      _Directory.create.<anonymous closure> (dart:io/directory_impl.dart:122:11)
[  +34 ms] E/flutter (15546): #1      _rootRunUnary (dart:async/zone.dart:1132:38)
[  +48 ms] E/flutter (15546): #2      _CustomZone.runUnary (dart:async/zone.dart:1029:19)
[ +130 ms] E/flutter (15546): #3      _FutureListener.handleValue (dart:async/future_impl.dart:126:18)
[   +3 ms] E/flutter (15546): #4      Future._propagateToListeners.handleValueCallback
(dart:async/future_impl.dart:639:45)
[  +31 ms] E/flutter (15546): #5      Future._propagateToListeners (dart:async/future_impl.dart:668:32)
[  +13 ms] E/flutter (15546): #6      Future._completeWithValue (dart:async/future_impl.dart:483:5)
[  +48 ms] E/flutter (15546): #7      Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:513:7)
[  +22 ms] E/flutter (15546): #8      _rootRun (dart:async/zone.dart:1124:13)
[  +46 ms] E/flutter (15546): #9      _CustomZone.run (dart:async/zone.dart:1021:19)
[  +17 ms] E/flutter (15546): #10     _CustomZone.runGuarded (dart:async/zone.dart:923:7)
[  +69 ms] E/flutter (15546): #11     _CustomZone.bindCallbackGuarded.<anonymous closure>
(dart:async/zone.dart:963:23)
[  +28 ms] E/flutter (15546): #12     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
[   +6 ms] E/flutter (15546): #13     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
[   +1 ms] E/flutter (15546): 
[   +2 ms] E/flutter (15546): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: FileSystemException:
Directory listing failed, path = '/storage/emulated/0/bizzapp/MData/' (OS Error: No such file or directory, errno =
2)
[   +4 ms] E/flutter (15546): null
[   +1 ms] E/flutter (15546): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: FileSystemException:
Creation failed, path = '/storage/emulated/0/bizzapp' (OS Error: Permission denied, errno = 13)
[   +1 ms] E/flutter (15546): #0      _Directory.create.<anonymous closure> (dart:io/directory_impl.dart:122:11)
[   +1 ms] E/flutter (15546): #1      _rootRunUnary (dart:async/zone.dart:1132:38)
[        ] E/flutter (15546): #2      _CustomZone.runUnary (dart:async/zone.dart:1029:19)
[   +2 ms] E/flutter (15546): #3      _FutureListener.handleValue (dart:async/future_impl.dart:126:18)
[        ] E/flutter (15546): #4      Future._propagateToListeners.handleValueCallback
(dart:async/future_impl.dart:639:45)
[  +14 ms] E/flutter (15546): #5      Future._propagateToListeners (dart:async/future_impl.dart:668:32)
[   +2 ms] E/flutter (15546): #6      Future._completeWithValue (dart:async/future_impl.dart:483:5)
[        ] E/flutter (15546): #7      Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:513:7)
[  +11 ms] E/flutter (15546): #8      _rootRun (dart:async/zone.dart:1124:13)
[        ] E/flutter (15546): #9      _CustomZone.run (dart:async/zone.dart:1021:19)
[        ] E/flutter (15546): #10     _CustomZone.runGuarded (dart:async/zone.dart:923:7)
[   +1 ms] E/flutter (15546): #11     _CustomZone.bindCallbackGuarded.<anonymous closure>
(dart:async/zone.dart:963:23)
[  +12 ms] E/flutter (15546): #12     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
[   +9 ms] E/flutter (15546): #13     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
[  +98 ms] E/flutter (15546): 
[  +96 ms] E/flutter (15546): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: FileSystemException:
Creation failed, path = '/storage/emulated/0/bizzapp' (OS Error: Permission denied, errno = 13)
[  +37 ms] E/flutter (15546): #0      _Directory.create.<anonymous closure> (dart:io/directory_impl.dart:122:11)
[   +5 ms] E/flutter (15546): #1      _rootRunUnary (dart:async/zone.dart:1132:38)
[   +1 ms] E/flutter (15546): #2      _CustomZone.runUnary (dart:async/zone.dart:1029:19)
[        ] E/flutter (15546): #3      _FutureListener.handleValue (dart:async/future_impl.dart:126:18)
[        ] E/flutter (15546): #4      Future._propagateToListeners.handleValueCallback
(dart:async/future_impl.dart:639:45)
[ +119 ms] E/flutter (15546): #5      Future._propagateToListeners (dart:async/future_impl.dart:668:32)
[ +301 ms] E/flutter (15546): #6      Future._completeWithValue (dart:async/future_impl.dart:483:5)
[ +345 ms] E/flutter (15546): #7      Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:513:7)
[ +339 ms] E/flutter (15546): #8      _rootRun (dart:async/zone.dart:1124:13)
[   +8 ms] E/flutter (15546): #9      _CustomZone.run (dart:async/zone.dart:1021:19)
[   +1 ms] E/flutter (15546): #10     _CustomZone.runGuarded (dart:async/zone.dart:923:7)
[        ] E/flutter (15546): #11     _CustomZone.bindCallbackGuarded.<anonymous closure>
(dart:async/zone.dart:963:23)
[   +1 ms] E/flutter (15546): #12     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
[   +1 ms] E/flutter (15546): #13     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
[        ] E/flutter (15546): 
[+6114 ms] Updating files
[ +376 ms] DevFS: Sync finished
[   +5 ms] Syncing files to device ASUS X00TD... (completed in 11,674ms, longer than expected)
[   +1 ms] Synced 0.9MB.
[   +2 ms] Sending to VM service: _flutter.listViews({})
[  +24 ms] Result: {type: FlutterViewList, views: [{type: FlutterView, id: _flutterView/0x76af632218, isolate: {type:@Isolate, fixedId: true, id: isolates/473463297, name: main.dart$main-473463297, number: 473463297}}]}
[   +5 ms] Connected to _flutterView/0x76af632218.
[  +13 ms] 🔥  To hot reload changes while running, press "r". To hot restart (and rebuild state), press "R".
[  +14 ms] An Observatory debugger and profiler on ASUS X00TD is available at: http://127.0.0.1:58254/
[   +1 ms] For a more detailed help message, press "h". To detach, press "d"; to quit, press "q".
[+14957 ms] I/flutter (15546): [Instance of 'Permissions']  // **### _Here I Pressed Allow for Storage permission request_** 
[+6970 ms] I/flutter (15546): PermissionStatus.allow
[ +266 ms] E/flutter (15546): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: FileSystemException:
Directory listing failed, path = '/storage/emulated/0/bizzapp/MData/' (OS Error: No such file or directory, errno =
2)
[   +1 ms] E/flutter (15546): null
[  +70 ms] E/flutter (15546): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: FileSystemException:
Creation failed, path = '/storage/emulated/0/bizzapp' (OS Error: Permission denied, errno = 13)
[   +2 ms] E/flutter (15546): #0      _Directory.create.<anonymous closure> (dart:io/directory_impl.dart:122:11)
[   +1 ms] E/flutter (15546): #1      _rootRunUnary (dart:async/zone.dart:1132:38)
[   +1 ms] E/flutter (15546): #2      _CustomZone.runUnary (dart:async/zone.dart:1029:19)
[        ] E/flutter (15546): #3      _FutureListener.handleValue (dart:async/future_impl.dart:126:18)
[   +1 ms] E/flutter (15546): #4      Future._propagateToListeners.handleValueCallback
(dart:async/future_impl.dart:639:45)
[   +2 ms] E/flutter (15546): #5      Future._propagateToListeners (dart:async/future_impl.dart:668:32)
[   +2 ms] E/flutter (15546): #6      Future._completeWithValue (dart:async/future_impl.dart:483:5)
[   +1 ms] E/flutter (15546): #7      Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:513:7)
[   +1 ms] E/flutter (15546): #8      _rootRun (dart:async/zone.dart:1124:13)
[        ] E/flutter (15546): #9      _CustomZone.run (dart:async/zone.dart:1021:19)
[   +1 ms] E/flutter (15546): #10     _CustomZone.runGuarded (dart:async/zone.dart:923:7)
[   +1 ms] E/flutter (15546): #11     _CustomZone.bindCallbackGuarded.<anonymous closure>
(dart:async/zone.dart:963:23)
[   +1 ms] E/flutter (15546): #12     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
[        ] E/flutter (15546): #13     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
[   +1 ms] E/flutter (15546): 
[ +200 ms] I/chatty  (15546): uid=10253(com.example.bizzappv2) Thread-2 identical 1 line
[   +3 ms] E/flutter (15546): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: FileSystemException:
Creation failed, path = '/storage/emulated/0/bizzapp' (OS Error: Permission denied, errno = 13)
[   +2 ms] E/flutter (15546): #0      _Directory.create.<anonymous closure> (dart:io/directory_impl.dart:122:11)
[   +1 ms] E/flutter (15546): #1      _rootRunUnary (dart:async/zone.dart:1132:38)
[   +1 ms] E/flutter (15546): #2      _CustomZone.runUnary (dart:async/zone.dart:1029:19)
[   +1 ms] E/flutter (15546): #3      _FutureListener.handleValue (dart:async/future_impl.dart:126:18)
[        ] E/flutter (15546): #4      Future._propagateToListeners.handleValueCallback
(dart:async/future_impl.dart:639:45)
[        ] E/flutter (15546): #5      Future._propagateToListeners (dart:async/future_impl.dart:668:32)
[        ] E/flutter (15546): #6      Future._completeWithValue (dart:async/future_impl.dart:483:5)
[        ] E/flutter (15546): #7      Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:513:7)
[        ] E/flutter (15546): #8      _rootRun (dart:async/zone.dart:1124:13)
[        ] E/flutter (15546): #9      _CustomZone.run (dart:async/zone.dart:1021:19)
[        ] E/flutter (15546): #10     _CustomZone.runGuarded (dart:async/zone.dart:923:7)
[        ] E/flutter (15546): #11     _CustomZone.bindCallbackGuarded.<anonymous closure>
(dart:async/zone.dart:963:23)
[        ] E/flutter (15546): #12     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
[        ] E/flutter (15546): #13     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
[   +1 ms] E/flutter (15546): 
[ +125 ms] E/flutter (15546): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: FileSystemException:
Directory listing failed, path = '/storage/emulated/0/bizzapp/MData/' (OS Error: No such file or directory, errno =
2)
[   +1 ms] E/flutter (15546): null
[   +2 ms] E/flutter (15546): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: FileSystemException:
Creation failed, path = '/storage/emulated/0/bizzapp' (OS Error: Permission denied, errno = 13)
[   +3 ms] E/flutter (15546): #0      _Directory.create.<anonymous closure> (dart:io/directory_impl.dart:122:11)
[  +19 ms] E/flutter (15546): #1      _rootRunUnary (dart:async/zone.dart:1132:38)
[   +2 ms] E/flutter (15546): #2      _CustomZone.runUnary (dart:async/zone.dart:1029:19)
[        ] E/flutter (15546): #3      _FutureListener.handleValue (dart:async/future_impl.dart:126:18)
[        ] E/flutter (15546): #4      Future._propagateToListeners.handleValueCallback
(dart:async/future_impl.dart:639:45)
[   +1 ms] E/flutter (15546): #5      Future._propagateToListeners (dart:async/future_impl.dart:668:32)
[        ] E/flutter (15546): #6      Future._completeWithValue (dart:async/future_impl.dart:483:5)
[        ] E/flutter (15546): #7      Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:513:7)
[        ] E/flutter (15546): #8      _rootRun (dart:async/zone.dart:1124:13)
[        ] E/flutter (15546): #9      _CustomZone.run (dart:async/zone.dart:1021:19)
[        ] E/flutter (15546): #10     _CustomZone.runGuarded (dart:async/zone.dart:923:7)
[        ] E/flutter (15546): #11     _CustomZone.bindCallbackGuarded.<anonymous closure>
(dart:async/zone.dart:963:23)
[   +5 ms] E/flutter (15546): #12     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
[   +1 ms] E/flutter (15546): #13     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
[   +1 ms] E/flutter (15546): 
[  +18 ms] I/chatty  (15546): uid=10253(com.example.bizzappv2) Thread-2 identical 1 line
[   +3 ms] E/flutter (15546): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: FileSystemException:
Creation failed, path = '/storage/emulated/0/bizzapp' (OS Error: Permission denied, errno = 13)
[   +1 ms] E/flutter (15546): #0      _Directory.create.<anonymous closure> (dart:io/directory_impl.dart:122:11)
[   +1 ms] E/flutter (15546): #1      _rootRunUnary (dart:async/zone.dart:1132:38)
[   +1 ms] E/flutter (15546): #2      _CustomZone.runUnary (dart:async/zone.dart:1029:19)
[   +1 ms] E/flutter (15546): #3      _FutureListener.handleValue (dart:async/future_impl.dart:126:18)
[   +1 ms] E/flutter (15546): #4      Future._propagateToListeners.handleValueCallback
(dart:async/future_impl.dart:639:45)
[   +1 ms] E/flutter (15546): #5      Future._propagateToListeners (dart:async/future_impl.dart:668:32)
[        ] E/flutter (15546): #6      Future._completeWithValue (dart:async/future_impl.dart:483:5)
[        ] E/flutter (15546): #7      Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:513:7)
[        ] E/flutter (15546): #8      _rootRun (dart:async/zone.dart:1124:13)
[        ] E/flutter (15546): #9      _CustomZone.run (dart:async/zone.dart:1021:19)
[        ] E/flutter (15546): #10     _CustomZone.runGuarded (dart:async/zone.dart:923:7)
[        ] E/flutter (15546): #11     _CustomZone.bindCallbackGuarded.<anonymous closure>
(dart:async/zone.dart:963:23)
[   +1 ms] E/flutter (15546): #12     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
[        ] E/flutter (15546): #13     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
[   +1 ms] E/flutter (15546): 
[ +893 ms] I/flutter (15546): PermissionStatus.allow
[  +46 ms] E/flutter (15546): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: FileSystemException:
Directory listing failed, path = '/storage/emulated/0/bizzapp/MData/' (OS Error: No such file or directory, errno =
2)
[   +2 ms] E/flutter (15546): null
[        ] E/flutter (15546): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: FileSystemException:
Creation failed, path = '/storage/emulated/0/bizzapp' (OS Error: Permission denied, errno = 13)
[   +1 ms] E/flutter (15546): #0      _Directory.create.<anonymous closure> (dart:io/directory_impl.dart:122:11)
[   +1 ms] E/flutter (15546): #1      _rootRunUnary (dart:async/zone.dart:1132:38)
[        ] E/flutter (15546): #2      _CustomZone.runUnary (dart:async/zone.dart:1029:19)
[        ] E/flutter (15546): #3      _FutureListener.handleValue (dart:async/future_impl.dart:126:18)
[        ] E/flutter (15546): #4      Future._propagateToListeners.handleValueCallback
(dart:async/future_impl.dart:639:45)
[   +2 ms] E/flutter (15546): #5      Future._propagateToListeners (dart:async/future_impl.dart:668:32)
[   +2 ms] E/flutter (15546): #6      Future._completeWithValue (dart:async/future_impl.dart:483:5)
[   +5 ms] E/flutter (15546): #7      Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:513:7)
[   +2 ms] E/flutter (15546): #8      _rootRun (dart:async/zone.dart:1124:13)
[   +1 ms] E/flutter (15546): #9      _CustomZone.run (dart:async/zone.dart:1021:19)
[   +1 ms] E/flutter (15546): #10     _CustomZone.runGuarded (dart:async/zone.dart:923:7)
[   +1 ms] E/flutter (15546): #11     _CustomZone.bindCallbackGuarded.<anonymous closure>
(dart:async/zone.dart:963:23)
[   +1 ms] E/flutter (15546): #12     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
[        ] E/flutter (15546): #13     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
[        ] E/flutter (15546): 
[   +1 ms] I/chatty  (15546): uid=10253(com.example.bizzappv2) Thread-2 identical 1 line
[        ] E/flutter (15546): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: FileSystemException:
Creation failed, path = '/storage/emulated/0/bizzapp' (OS Error: Permission denied, errno = 13)
[   +7 ms] E/flutter (15546): #0      _Directory.create.<anonymous closure> (dart:io/directory_impl.dart:122:11)
[   +2 ms] E/flutter (15546): #1      _rootRunUnary (dart:async/zone.dart:1132:38)
[   +1 ms] E/flutter (15546): #2      _CustomZone.runUnary (dart:async/zone.dart:1029:19)
[        ] E/flutter (15546): #3      _FutureListener.handleValue (dart:async/future_impl.dart:126:18)
[        ] E/flutter (15546): #4      Future._propagateToListeners.handleValueCallback
(dart:async/future_impl.dart:639:45)
[   +1 ms] E/flutter (15546): #5      Future._propagateToListeners (dart:async/future_impl.dart:668:32)
[   +1 ms] E/flutter (15546): #6      Future._completeWithValue (dart:async/future_impl.dart:483:5)
[   +1 ms] E/flutter (15546): #7      Future._asyncComplete.<anonymous closure> (dart:async/future_impl.dart:513:7)
[   +4 ms] E/flutter (15546): #8      _rootRun (dart:async/zone.dart:1124:13)
[  +23 ms] E/flutter (15546): #9      _CustomZone.run (dart:async/zone.dart:1021:19)
[   +1 ms] E/flutter (15546): #10     _CustomZone.runGuarded (dart:async/zone.dart:923:7)
[        ] E/flutter (15546): #11     _CustomZone.bindCallbackGuarded.<anonymous closure>
(dart:async/zone.dart:963:23)
[        ] E/flutter (15546): #12     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
[        ] E/flutter (15546): #13     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
[        ] E/flutter (15546): 
[ +138 ms] I/flutter (15546): FileSystemException: Cannot open file, path =
'/storage/emulated/0/bizzapp/zip/745570098.zip' (OS Error: No such file or directory, errno = 2)

flutter analyze

Analyzing bizzappv2...
No issues found! (ran in 37.9s)

Flutter Doctor

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.2.1, on Microsoft Windows [Version 10.0.17134.706], locale en-IN)
[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[√] Android Studio (version 3.3)
[√] VS Code (version 1.33.1)
[√] VS Code, 64-bit edition (version 1.31.1)
[√] Connected device (1 available)

• No issues found!
@krngd2
Copy link
Author

krngd2 commented Apr 19, 2019

3 days no reply from anyone, Still struggling to get a solution

@DanTup
Copy link
Contributor

DanTup commented Apr 19, 2019

@krngd2 Can you share a small, but complete code sample that can be used to try and reproduce? Ideally a repo that includes pubspec with the correct plugin dependencies etc.

@krngd2
Copy link
Author

krngd2 commented Apr 22, 2019

@DanTup Thank you for the response, here is the repo

@DanTup
Copy link
Contributor

DanTup commented Apr 22, 2019

Thanks! I tried running this (from VS Code, using current Flutter master channel) on a physical Moto X Play (running Android 7.1.1) and I got this in the Debug Console:

Launching lib/main.dart on XT1562 in debug mode...
Built build/app/outputs/apk/debug/app-debug.apk.
I/flutter ( 7242): PermissionStatus.notAgain

And the storage permission dialog popped up. I approved access, then it wrote:

I/flutter ( 7242): Creating Directory

I guess this is what's supposed to happen, and not what you're seeing? What sort of device are you running on? What version of Android and Flutter are you using? Can you repro on another device (for ex. emulator)?

@DanTup
Copy link
Contributor

DanTup commented Apr 22, 2019

Apparently my phone has Google Play services updates and is failing to update, so I'll try again once that finishes.

Btw, I noticed in the docs here:

https://developer.android.com/reference/android/Manifest.permission.html#WRITE_EXTERNAL_STORAGE

It says that WRITE_EXTERNAL_STORAGE is being deprecated in Q. I think that's the permission being used here. I presume you're not using Q, but it's possible you might need to tweak things for this in future.

@krngd2
Copy link
Author

krngd2 commented Apr 23, 2019

I am using a physical device Asus Zenfone Max pro M1 running on Andrpid N. And yes i am using the external storage. Now i changed it to getApplicationDocumentsDirectory() and its working fine without errors . I wonder what was the issue previously.
Thanks for the suggestions.

@DanTup
Copy link
Contributor

DanTup commented Apr 23, 2019

I found some comments on SO suggesting it might not work (for ex. https://stackoverflow.com/a/12853922/25124) but I'm not sure why it differed by device. I think moving off it is the best option though, since it seems in Q you won't have an option.

I don't think there's anything for Flutter to do here (the permissions are enforced by Android) and since there seems to be a good alternative, I'll close this. Thanks!

@DanTup DanTup closed this as completed Apr 23, 2019
@kamlesh9070
Copy link

@krngd2 If you are testing in Android Oreo then you need to ask WRITE_EXTERNAL_STORAGE

According to "https://developer.android.com/about/versions/oreo/android-8.0-changes.html#rmp"

If the app targets Android 8.0 (API level 26), the system grants only
READ_EXTERNAL_STORAGE at that time; however, if the app later requests
WRITE_EXTERNAL_STORAGE, the system immediately grants that privilege
without prompting the user.

PermissionPlugin ask only READ_EXTERNAL_STORAGE permission by Permission.requestPermissions([PermissionName**.Storage**]);
so You need to ask for WRITE_EXTERNAL_STORAGE.

You can use my repo for asking WRITE_EXTERNAL_STORAGE:
permission:
git:
url: https://github.com/kamlesh9070/permission

@ChetnaNakum
Copy link

I am facing the same issue. I have already granted Storage (Read/write) permission. But I can not perform write file operation on flutter( On and above oreo version android devices).

@kamlesh9070
Copy link

kamlesh9070 commented Jul 25, 2019

I am facing the same issue. I have already granted Storage (Read/write) permission. But I can not perform write file operation on flutter( On and above oreo version android devices).

Please refer my above post, Your problem should be resolved by using my git repo

Add this in your pubspec.yaml
permission: git: url: https://github.com/kamlesh9070/permission

@faithomotoso
Copy link

I am facing the same issue. I have already granted Storage (Read/write) permission. But I can not perform write file operation on flutter( On and above oreo version android devices).

Please refer my above post, Your problem should be resolved by using my git repo

Add this in your pubspec.yaml
permission: git: url: https://github.com/kamlesh9070/permission

Adding that to pubspec doesn't work. Any other way?

@oliverbytes
Copy link

I'm facing the same issue. How do we access the Downloads folder for devices without External SD Storage option?

@skj-skj
Copy link

skj-skj commented Aug 23, 2020

[Possible Solution]:
I am running a flutter app in a physical device (Android 10), also using Android Studio IDE
I faced this same issue, even after giving permission in the manifesto.
still not working.
then I manually uninstall the app from the physical device.
run the app again in the android studio, (app got build and install on the physical device).

and magically the problem gets solved (I don't know how).

Edit: you have to allow Storage permission from the app settings.

@vmwsree
Copy link

vmwsree commented Sep 13, 2020

Edit: you have to allow Storage permission from the app settings.

I did the same but still write is failing, Same code is working on other devices. also This was working on my device previously.

@sanjay23singh
Copy link

If the problem is on andoid 10 , try making the targetSdk version to 28 in build.gradle file. That worked for me.

@hey-om7
Copy link

hey-om7 commented Mar 30, 2021

<application
android:requestLegacyExternalStorage="true"

add this in the manifest ...it works 100% at least it did for me!!!

@Abhishek-Chougule
Copy link

I am using a physical device Asus Zenfone Max pro M1 running on Andrpid N. And yes i am using the external storage. Now i changed it to getApplicationDocumentsDirectory() and its working fine without errors . I wonder what was the issue previously.
Thanks for the suggestions.

I was having the same issue app perfectly work on below android 10 but not working for above android 10 version devices : (

@sanjay23singh
Copy link

If the problem is on andoid 10 , try making the targetSdk version to 28 in build.gradle file. That worked for me.

@Abhishek-Chougule see this

@Abhishek-Chougule
Copy link

@sanjay23singh is works but I want to build app for Android 10.

@github-actions
Copy link

github-actions bot commented Aug 2, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests