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

Unable to Write File in Selected Path #396

Closed
LibertyBeta opened this issue Sep 19, 2020 · 8 comments
Closed

Unable to Write File in Selected Path #396

LibertyBeta opened this issue Sep 19, 2020 · 8 comments
Labels
android Issue applies to Android platform needs investigation on hold

Comments

@LibertyBeta
Copy link

Describe the bug
After succesfully picking a path, I am unable to then write files/edit files in that path. This is fairly important as they are choosing where to save a sqlite DB.

Issue details

  1. Android
  2. 11
  3. Detailed steps to reproduce
  • Pick a Directory with getDirectoryPath
  • Get asked classic "Allow apps write permissions"
  • Open native file picker, not in /
  • Go to dir.
  • Tap Select

Error Log
D/FilePickerDelegate(29855): [SingleFilePick] File URI:content://com.android.externalstorage.documents/tree/primary%3Akanso/document/primary%3Akanso
W/p.plaster.kans(29855): Accessing hidden method Landroid/os/storage/StorageManager;->getVolumeList()[Landroid/os/storage/StorageVolume; (greylist, reflection, allowed)
W/p.plaster.kans(29855): Accessing hidden method Landroid/os/storage/StorageVolume;->getPath()Ljava/lang/String; (greylist-max-q,test-api, reflection, allowed)
I/flutter (29855): /storage/emulated/0/kanso
E/flutter (29855): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: FileSystemException: Cannot create file, path = '/storage/emulated/0/kanso/entries.db' (OS Error: Operation not permitted, errno = 1)
E/flutter (29855): #0 _File.throwIfError (dart:io/file_impl.dart:635:7)
E/flutter (29855): #1 _File.createSync (dart:io/file_impl.dart:273:5)
E/flutter (29855): #2 AppState.setupRoot (package:kanso/providers/app.dart:119:12)
E/flutter (29855):
E/flutter (29855): #3 OnBoard.build. (package:kanso/views/onboard.dart:13:61)
E/flutter (29855): #4 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:993:19)
E/flutter (29855): #5 _InkResponseState.build. (package:flutter/src/material/ink_well.dart:1111:38)
E/flutter (29855): #6 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:183:24)
E/flutter (29855): #7 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:598:11)
E/flutter (29855): #8 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:287:5)
E/flutter (29855): #9 BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:222:7)
E/flutter (29855): #10 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:476:9)
E/flutter (29855): #11 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:77:12)
E/flutter (29855): #12 PointerRouter._dispatchEventToRoutes. (package:flutter/src/gestures/pointer_router.dart:122:9)
E/flutter (29855): #13 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:377:8)
E/flutter (29855): #14 PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:120:18)
E/flutter (29855): #15 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:106:7)
E/flutter (29855): #16 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:370:19)
E/flutter (29855): #17 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:350:22)
E/flutter (29855): #18 RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:266:11)
E/flutter (29855): #19 GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:305:7)
E/flutter (29855): #20 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:240:7)
E/flutter (29855): #21 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:213:7)
E/flutter (29855): #22 _rootRunUnary (dart:async/zone.dart:1206:13)
E/flutter (29855): #23 _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter (29855): #24 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
E/flutter (29855): #25 _invoke1 (dart:ui/hooks.dart:265:10)
E/flutter (29855): #26 _dispatchPointerDataPacket (dart:ui/hooks.dart:174:5)
E/flutter (29855):

@LibertyBeta LibertyBeta added the new issue An issue that hasn't yet been seen from the maintainer label Sep 19, 2020
@miguelpruivo
Copy link
Owner

@LibertyBeta which directory are you picking? There are some dirs that are protected by OS and can’t be directly written (such as downloads folder).

@miguelpruivo miguelpruivo added triage Further information is requested and removed new issue An issue that hasn't yet been seen from the maintainer labels Sep 19, 2020
@LibertyBeta
Copy link
Author

LibertyBeta commented Sep 19, 2020

If you look at the log it's a folder I created for the purpose of putting stuff for the app in it. And the library returns the path fine.

Edit: I'll try to get a minimal viable reproduction example put together tonight.

@miguelpruivo
Copy link
Owner

@LibertyBeta this seems to be a common issue with Flutter accessing some directories for writing. Found some threads like this.

Someone suggested that using requestLegacyStorage = true on your manifest file (under Application tag) fixed it. See here. Would you mind to try and see if it worked for you?

Thank you!

@miguelpruivo miguelpruivo added android Issue applies to Android platform needs investigation and removed triage Further information is requested labels Sep 19, 2020
@LibertyBeta
Copy link
Author

That flag doesn't work in 11, as its been deprecated.

@miguelpruivo
Copy link
Owner

@LibertyBeta I really would like to help you, however it seems that everything should work as it is. 😔

As you can see, there are similar reported issues with other plugins that try to write/use path permissions. This could be a something with Flutter, but I’m out on vacations and I might do a further investigation when I come back.

Have you tried creating the file with a different name, for example?

@LibertyBeta
Copy link
Author

I have. I'm going to try an MVP of the file management api for 11 on my own and compare the differences. I'll get back to you with my research.

@miguelpruivo
Copy link
Owner

That would be great. If there’s anything I can do to help, let me know.

I’ll set this on hold until further details.

Thank you.

@LibertyBeta
Copy link
Author

See #394

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android Issue applies to Android platform needs investigation on hold
Projects
None yet
Development

No branches or pull requests

2 participants