I am using the file picker with type set to FileType.ANY on a Pixel 3. If I select a file of type PDF then I get a crash as shown below:
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=33115, result=-1, data=Intent { dat=content://com.android.providers.downloads.documents/document/msf:2507 flg=0x1 }} to activity {}:
java.lang.NumberFormatException: For input string: "msf:2507"
E/AndroidRuntime(16157): at android.app.ActivityThread.deliverResults(ActivityThread.java:4843)
E/AndroidRuntime(16157): at android.app.ActivityThread.handleSendResult(ActivityThread.java:4884)
E/AndroidRuntime(16157): at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51)
E/AndroidRuntime(16157): at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
E/AndroidRuntime(16157): at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
E/AndroidRuntime(16157): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
E/AndroidRuntime(16157): at android.os.Handler.dispatchMessage(Handler.java:107)
E/AndroidRuntime(16157): at android.os.Looper.loop(Looper.java:214)
E/AndroidRuntime(16157): at android.app.ActivityThread.main(ActivityThread.java:7343)
E/AndroidRuntime(16157): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(16157): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/AndroidRuntime(16157): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:933)
E/AndroidRuntime(16157): Caused by: java.lang.NumberFormatException: For input string: "msf:2507"
E/AndroidRuntime(16157): at java.lang.Long.parseLong(Long.java:594)
E/AndroidRuntime(16157): at java.lang.Long.valueOf(Long.java:808)
E/AndroidRuntime(16157): at com.mr.flutter.plugin.filepicker.FileUtils.getForApi19(FileUtils.java:69)
E/AndroidRuntime(16157): at com.mr.flutter.plugin.filepicker.FileUtils.getPath(FileUtils.java:29)
E/AndroidRuntime(16157): at com.mr.flutter.plugin.filepicker.FilePickerPlugin$1.onActivityResult(FilePickerPlugin.java:81)
E/AndroidRuntime(16157): at io.flutter.app.FlutterPluginRegistry.onActivityResult(FlutterPluginRegistry.java:204)
E/AndroidRuntime(16157): at io.flutter.app.FlutterActivityDelegate.onActivityResult(FlutterActivityDelegate.java:132)
E/AndroidRuntime(16157): at io.flutter.app.FlutterActivity.onActivityResult(FlutterActivity.java:142)
E/AndroidRuntime(16157): at android.app.Activity.dispatchActivityResult(Activity.java:8110)
E/AndroidRuntime(16157): at android.app.ActivityThread.deliverResults(ActivityThread.java:4836)
If seems somewhat similar to this issue: https://github.com/miguelpruivo/plugins_flutter_file_picker/issues/7
Hi,
What’s the target API of your app and also what’s the emulator version? Where are you trying to select the file (which folder)? Can you try with a different pdf a let me know if it works for you?
Thank you.
Target API is 28. It is failing on my phone, not the emulator (my test on the emulator it worked fine as well). My phone is running Android Q B5. It appears to only crash when accessing certain PDF files. These files are in the downloads folder and were downloaded from the browser. I can open these files fine using the built-in viewer.
A few other notes. The crash is fatal and shuts down the VM and thus can't be wrapped in a try/catch. A few more lines of the logcat.
> E/FilePickerUtils( 5279): Getting for API 19 or abovecontent://com.android.providers.downloads.documents/document/msf%3A2572
> E/FilePickerUtils( 5279): Document URI
> E/FilePickerUtils( 5279): Downloads External Document URI
> D/AndroidRuntime( 5279): Shutting down VM
> E/AndroidRuntime( 5279): FATAL EXCEPTION: main
>
Thank you for the details @gerryhigh, can you post the output of your flutter doctor -v with the running emulador (where the issue happens)?
Also, if you can give me with the steps to replicate it, it would be fine as it is quite hard to replicate some of these issues due to Android fragmentation.
Thank you.
Output:
`[√] Flutter (Channel master, v1.8.2-pre.181, on Microsoft Windows [Version 10.0.18362.239], locale en-US)
• Flutter version 1.8.2-pre.181 at c:\projects\flutter
• Framework revision c15cfdd6af (2 days ago), 2019-07-24 22:44:12 -0700
• Engine revision 72341ed032
• Dart version 2.5.0 (build 2.5.0-dev.1.0 0c97c31b6e)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.0)
• Android SDK at \Local\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
• All Android licenses accepted.
[√] Android Studio (version 3.4)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 37.1.1
• Dart plugin version 183.6270
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
[√] VS Code (version 1.36.1)
• VS Code at \Local\Programs\Microsoft VS Code
• Flutter extension version 3.2.0
[√] Connected device (1 available)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)
• No issues found!`
To reproduce it's very simple. Just call await FilePicker.getFilePath(type: FileType.ANY); and pick the file and it will crash the app completely.
same error here, pdf files causes a crash in android.
@m7mdra in which device? There are some device/version specific issues that have been very hard to replicate so they can be fixed.
Thank you.
@miguelpruivo
im using pixle running android Q, i think that might be the problem.
its working fine in a real device but not when using emulator.
Thanks.
After testing on android P i can confirm its working fine.
thanks for the good job
@m7mdra usually I can’t replicate this issue on an emulator as it typically happens on real devices. If you are able to reproduce this issue on an emulator, would you mind to fully post your logs and the output of your flutter doctor -v with that emulator on?
Thank you!
@miguelpruivo for unobvious reason restarting the emulator fixed the bug, i tried to reproudced it but it worked so i guess its all good.
Thanks for following up.
@gerryhigh this should be fixed right now in the 1.4.0 that is yet on beta. Could you please try replacing in your pubspec.yaml like so:
file_picker:
git:
url: https://github.com/miguelpruivo/plugins_flutter_file_picker.git
ref: beta
and let me know if it's working for you?
Thank you.
Version 1.4.0 published with these changes. Thank you for reporting. 🎉
@miguelpruivo I still have the same issue. I am using version 1.9.0.1.
flutter doctor -v
[✓] Flutter (Channel dev, v1.18.0, on Mac OS X 10.14.4 18E226, locale en-CA)
• Flutter version 1.18.0 at /Users/xdev/development/flutter
• Framework revision 8f7327f83a (8 weeks ago), 2020-04-06 22:11:01 -0400
• Engine revision 49891e0653
• Dart version 2.8.0 (build 2.8.0-dev.20.0 1210d27678)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at /Users/xdev/Library/Android/sdk
• Platform android-29, build-tools 29.0.3
• ANDROID_HOME = /Users/xdev/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
✗ Android license status unknown.
Try re-installing or updating your Android SDK Manager.
See https://developer.android.com/studio/#downloads or visit visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed
instructions.
[!] Xcode - develop for iOS and macOS (Xcode 11.3.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.3.1, Build version 11C504
! CocoaPods 1.7.0 out of date (1.8.0 is recommended).
CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/platform-plugins
To upgrade:
sudo gem install cocoapods
[✓] Android Studio (version 3.5)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 43.0.1
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
[!] IntelliJ IDEA Community Edition (version 2019.3.2)
• IntelliJ at /Applications/IntelliJ IDEA CE.app
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• For information about installing plugins, see
https://flutter.dev/intellij-setup/#installing-the-plugins
[✓] VS Code (version 1.45.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.11.0
[✓] Connected device (5 available)
• Nexus 5X • 0081f8dd80c8c538 • android-arm64 • Android 8.1.0 (API 27)
• Nexus 5X • 00d78fb1278fa40a • android-arm64 • Android 8.1.0 (API 27)
• Android SDK built for x86 64 • emulator-5554 • android-x64 • Android 9 (API 28) (emulator)
• Android SDK built for x86 • emulator-5556 • android-x86 • Android 10 (API 29) (emulator)
• macOS • macOS • darwin-x64 • Mac OS X 10.14.4 18E226
! Doctor found issues in 3 categories.
@miguelpruivo Same issue occured i am using 2.1.0
Most helpful comment
@miguelpruivo for unobvious reason restarting the emulator fixed the bug, i tried to reproudced it but it worked so i guess its all good.
Thanks for following up.