Closed gilvangobbato closed 4 years ago
Hum, this is odd. How are you picking the file?
Hum, this is odd. How are you picking the file?
Maybe could be this the problem... In this case I'm using image_picker plugin
ImagePicker.pickImage( source: ImageSource.gallery, maxWidth: 1024, maxHeight: 1024, )
I'm changing to use only file_picker, maybe it will resolve, so, I can't use both
I've tried, and de error keep, I don't understand how is possible that it is opening a audio record?!?! It's strange
if I back to version 1.4.3+2 all is ok
@gilvangobbato you shouldn't have any issue using both. Actually, I recommend you to do so if you need to use camera or multi file gallery picking, for example.
However, you didn't answer my previous question: how are you using the FilePicker? Could you please post your code?
Thank you.
@gilvangobbato you shouldn't have any issue using both. Actually, I recommend you to do so if you need to use camera or multi file gallery picking, for example.
However, you didn't answer my previous question: how are you using the FilePicker? Could you please post your code?
Thank you.
Woow, sorry, you are rigth! For example in this case
List<File> files =
await FilePicker.getMultiFile(type: FileType.ANY, fileExtension: 'db');
or this
File file =
await FilePicker.getFile(type: FileType.ANY, fileExtension: 'csv');
@gilvangobbato does this happen with Android, iOS or both?
@gilvangobbato does this happen with Android, iOS or both?
Android, I'm not using iOS yet.
Ok. I'll take a look. That's really odd anyway, I'm not sure if I'm going to be able to replicate it.
I have the same issue here, I am using the FilePicker.getFile() method, like this:
return FloatingActionButton( onPressed: () async { var file = await FilePicker.getFile(); print(">>> ${file.path}"); } );
As you can see, I am calling it inside the onPressed of the FloatingActionButton. The file picker gets opened, and I can select a file, but it never returns the File and so the print() method never gets invoked.
I am using using Android 10 on an emulated device and Android 9 on a physical device.
Ok. I'll take a look. That's really odd anyway, I'm not sure if I'm going to be able to replicate it.
I'll try to build an application to help you
Ok. I'll take a look. That's really odd anyway, I'm not sure if I'm going to be able to replicate it.
So, I did and in the following example is possible to reproduce the error. https://github.com/gilvangobbato/file_demo.git
flutter doctor -v
[√] Flutter (Channel stable, v1.12.13+hotfix.8, on Microsoft Windows [version 10.0.18363.720], locale pt-BR) • Flutter version 1.12.13+hotfix.8 at C:\src\flutter • Framework revision 0b8abb4724 (6 weeks ago), 2020-02-11 11:44:36 -0800 • Engine revision e1e6ced81d • Dart version 2.7.0
[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3) • Android SDK at C:\Users\gilva\AppData\Local\Android\sdk • Android NDK location not configured (optional; useful for native profiling support) • Platform android-29, build-tools 28.0.3 • Java binary at: C:\Program Files\Android\Android Studio1\jre\bin\java • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04) • All Android licenses accepted.
[√] Android Studio (version 3.6) • Android Studio at C:\Program Files\Android\Android Studio1 • Flutter plugin version 44.0.2 • Dart plugin version 192.7761 • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
[√] VS Code (version 1.43.2) • VS Code at C:\Users\gilva\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.8.1
[√] Connected device (1 available) • CPH1707 • c4b5ca06 • android-arm64 • Android 7.1.1 (API 25)
• No issues found!
@hsalazarl this seems to not be related with this issue but something else. If your print clause never gets called that’s probably because an exception is being thrown somehow.
Wrap it with a try catch clause and let me know what it prints. Nevertheless, Android 10 requires legacy storage enabled on your manifest file or else won’t work (check this answer). I must add it to the wiki.
@gilvangobbato thank you! I’ll try to take a look ASAP and keep you updated.
@miguelpruivo agreed. I think my specific problem has to do with navigation. Because when I select the file, the FilePicker goes away, and it does not return with the File. But if at that moment I click Stop on AndroidStudio, the app closes but reveals the FilePicker. That's why on a second attempt to use it, it says that it is still active.
@hsalazarl I recommend you to run the example provided with the plugin and see if it works fine for you. If it does, then you should recheck your app’s logic for picking the file and make sure you don’t trigger multiple picks at once, regardless of it being protected from the plugin anyway.
I have the same problem
@gilvangobbato just noticed that your error is actually related to ImagePicker and not FilePicker.
@GiovaniTrevisol93 could you provide more details? The more we have, the better it gets to fix. Thanks!
@gilvangobbato just noticed that your error is actually related to ImagePicker and not FilePicker.
@GiovaniTrevisol93 could you provide more details? The more we have, the better it gets to fix. Thanks!
Yes, the error is on ImagePicker, but if I back the FilePicker version to 1.4.3+2 all is ok. So what I mean is that probably has some interference each other. I didn't try to back ImagePicker version, but I can do it to see the reaction.
@gilvangobbato would you mind checking and trying the purposed on this answer on a similar issue with PermissionHandler plugin? Someone found a cause and a solution.
Thank you.
@gilvangobbato would you mind checking and trying the purposed on this answer on a similar issue with PermissionHandler plugin? Someone found a cause and a solution.
Thank you.
So, thank you, I did the steps, this error (PlatformException) stops, but it continues open audio record. I will ask for some help in that plugin.
Thanks
The audio is something that I must take a look on. As for the exception itself, I’ll make sure I add it on the documentation as well because this is not the first time someone comes across this. It looks like you need to migrate your app to be compatible with V2 embedding, that’s why.
Thank you.
Thank you.
@gilvangobbato just found what was causing your record audio issue when opening the picker, you are using FileType.any
with csv
custom extension. You must use FileType.custom
when providing a custom extension.
However, it might be a good a idea for me to throw an exception when someone provides a custom format and selects other than FileType.custom
to prevent this kind of scenarios.
Thank you!
@gilvangobbato just found what was causing your record audio issue when opening the picker, you are using
FileType.any
withcsv
custom extension. You must useFileType.custom
when providing a custom extension.However, it might be a good a idea for me to throw an exception when someone provides a custom format and selects other than
FileType.custom
to prevent this kind of scenarios.Thank you!
Thank you for your help, but I think that the problem is my device, I tried but didn't solve. So, I've tested in other devices and it worked correctly and the issue is after request permisson and confirm, seriously, this is VERY strange, lol. I created an issue for permission_handler plugin to see if someone could help me.
But thanks for your attention.
Future<void> selectFile() async {
FilePickerResult? result = await FilePicker.platform.pickFiles(
type: FileType.custom,
allowedExtensions: ['pdf', 'jpg', 'jpeg', 'png'],
allowMultiple: false,
) ??
const FilePickerResult(<PlatformFile>[]);
if (result.files.isNotEmpty) {
File selected = File(result.files.single.path!);
String fileExtension = selected.path
.split('.')
.last
.toLowerCase();
if (fileExtension == 'pdf' ||
fileExtension == 'jpg' ||
fileExtension == 'jpeg' ||
fileExtension == 'png') {
int fileSize = selected.lengthSync();
if (fileSize <= 1024 * 1024) {
if (widget.dialogType == "postLeave") {
_allLeaveViewModel.selectedFile.value = selected;
print("SelectedFile1: ${_allLeaveViewModel.selectedFile.value}");
} else {
_myLeavesViewModel.selectedFile.value = selected;
print("SelectedFile2: ${_myLeavesViewModel.selectedFile.value}");
}
setState(() {
selectedFile = selected;
});
} else {
showFileSizeExceededDialog();
}
} else {
showInvalidFileTypeDialog();
}
}
}
I have two profiles on my phone: 1. personal profile and 2. work profile. The above-mentioned code works well in the personal profile, but when I try to run the same code in the work profile, it throws this error:
I/flutter (26152): [MethodChannelFilePicker] Platform exception: PlatformException(already_active, File picker is already active, null, null)
E/flutter (26152): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(already_active, File picker is already active, null, null)
E/flutter (26152): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:652:7)
E/flutter (26152): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:310:18)
E/flutter (26152): <asynchronous suspension>
E/flutter (26152): #2 MethodChannel.invokeListMethod (package:flutter/src/services/platform_channel.dart:496:35)
E/flutter (26152): <asynchronous suspension>
E/flutter (26152): #3 FilePickerIO._getPath (package:file_picker/src/file_picker_io.dart:92:33)
E/flutter (26152): <asynchronous suspension>
E/flutter (26152): #4 _UploadFileWidgetState.selectFile (package:feeta/views/other_widgets/upload_file_widget.dart:47:34)
E/flutter (26152): <asynchronous suspension>
E/flutter (26152):
F/crash_dump64(11881): crash_dump.cpp:494] failed to attach to thread 780: Permission denied
F/crash_dump64(12006): crash_dump.cpp:494] failed to attach to thread 809: Permission denied
@miguelpruivo Sir, could you please tell me why I am getting this error in the work profile especially, and why I am unable to pick files from the storage?
Devices in which this issue is occurring:
@hsalazarl I recommend you to run the example provided with the plugin and see if it works fine for you. If it does, then you should recheck your app’s logic for picking the file and make sure you don’t trigger multiple picks at once, regardless of it being protected from the plugin anyway.
Hey, I might be too late here, but is there any specific blockers that prevents to have multiple picks at once.
( I am picking a large file and while it is being loaded to cache, I am trying to pick a doc ).
I am facing Error in image picker: PlatformException(already_active, Image picker is already active, null, null) any solution ?
It's very strange, but when I start the application for the first time and it ask my to permission and after permit, the file picker open to me to record a audio. After that, if I try to add any file ocurs the error
Issue details
Error Log
Screenshots and/or video
Flutter Version details [√] Flutter (Channel stable, v1.12.13+hotfix.8, on Microsoft Windows [versão 10.0.18363.720], locale pt-BR) • Flutter version 1.12.13+hotfix.8 at C:\src\flutter • Framework revision 0b8abb4724 (6 weeks ago), 2020-02-11 11:44:36 -0800 • Engine revision e1e6ced81d • Dart version 2.7.0
[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3) • Android SDK at C:\Users\gilva\AppData\Local\Android\sdk • Android NDK location not configured (optional; useful for native profiling support) • Platform android-29, build-tools 28.0.3 • Java binary at: C:\Program Files\Android\Android Studio1\jre\bin\java • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04) • All Android licenses accepted.
[√] Android Studio (version 3.6) • Android Studio at C:\Program Files\Android\Android Studio1 • Flutter plugin version 44.0.2 • Dart plugin version 192.7761 • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
[√] VS Code (version 1.43.2) • VS Code at C:\Users\gilva\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.8.1
[√] Connected device (1 available) • CPH1707 • c4b5ca06 • android-arm64 • Android 7.1.1 (API 25)
• No issues found!
Additional context