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

Bug Report: NullPointerException in FilePicker on Android API 35 #1660

Open
vicajilau opened this issue Dec 30, 2024 · 1 comment
Open

Bug Report: NullPointerException in FilePicker on Android API 35 #1660

vicajilau opened this issue Dec 30, 2024 · 1 comment
Labels
new issue An issue that hasn't yet been seen from the maintainer

Comments

@vicajilau
Copy link

Summary

The app crashes when invoking the saveFile method from FilePicker on a device running Android API 35. The crash occurs due to a NullPointerException when attempting to write to a file.

Steps to Reproduce

  1. Use a device or emulator running Android API 35.
  2. Call the following method:
    return await FilePicker.platform.saveFile(
        dialogTitle: 'Please select an output file:',
        fileName: 'output-file.maso',
        initialDirectory: '/data/user/0/com.example.maso/cache/file_picker/1735558385877/example.maso');
    
  3. Select a file in the file picker dialog.

Expected Behavior

The file picker should successfully allow the user to save the file without crashing the app.

Actual Behavior

The app crashes with the following stack trace:

E/AndroidRuntime( 6271): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=43700, result=-1, data=Intent { dat=content://com.android.providers.downloads.documents/... flg=0x43 }} to activity {com.example.maso/com.example.maso.MainActivity}: java.lang.NullPointerException: Attempt to get length of null array
E/AndroidRuntime( 6271): 	at android.app.ActivityThread.deliverResults(ActivityThread.java:5878)
E/AndroidRuntime( 6271): 	at android.app.ActivityThread.handleSendResult(ActivityThread.java:5917)
E/AndroidRuntime( 6271): 	at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:69)
E/AndroidRuntime( 6271): 	at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:60)
E/AndroidRuntime( 6271): 	at android.app.servertransaction.TransactionExecutor.executeNonLifecycleItem(TransactionExecutor.java:174)
E/AndroidRuntime( 6271): 	at android.app.servertransaction.TransactionExecutor.executeTransactionItems(TransactionExecutor.java:109)
E/AndroidRuntime( 6271): 	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:81)
E/AndroidRuntime( 6271): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2636)
E/AndroidRuntime( 6271): 	at android.os.Handler.dispatchMessage(Handler.java:107)
E/AndroidRuntime( 6271): 	at android.os.Looper.loopOnce(Looper.java:232)
E/AndroidRuntime( 6271): 	at android.os.Looper.loop(Looper.java:317)
E/AndroidRuntime( 6271): 	at android.app.ActivityThread.main(ActivityThread.java:8705)
E/AndroidRuntime( 6271): 	at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 6271): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
E/AndroidRuntime( 6271): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886)
E/AndroidRuntime( 6271): Caused by: java.lang.NullPointerException: Attempt to get length of null array
E/AndroidRuntime( 6271): 	at java.io.FileOutputStream.write(FileOutputStream.java:409)
E/AndroidRuntime( 6271): 	at com.mr.flutter.plugin.filepicker.FilePickerDelegate.onActivityResult(FilePickerDelegate.java:84)
E/AndroidRuntime( 6271): 	at io.flutter.embedding.engine.FlutterEngineConnectionRegistry$FlutterEngineActivityPluginBinding.onActivityResult(FlutterEngineConnectionRegistry.java:774)
E/AndroidRuntime( 6271): 	at io.flutter.embedding.engine.FlutterEngineConnectionRegistry.onActivityResult(FlutterEngineConnectionRegistry.java:422)
E/AndroidRuntime( 6271): 	at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onActivityResult(FlutterActivityAndFragmentDelegate.java:964)
E/AndroidRuntime( 6271): 	at io.flutter.embedding.android.FlutterActivity.onActivityResult(FlutterActivity.java:911)
E/AndroidRuntime( 6271): 	at android.app.Activity.onActivityResult(Activity.java:7494)
E/AndroidRuntime( 6271): 	at android.app.Activity.internalDispatchActivityResult(Activity.java:9379)
E/AndroidRuntime( 6271): 	at android.app.Activity.dispatchActivityResult(Activity.java:9356)
E/AndroidRuntime( 6271): 	at android.app.ActivityThread.deliverResults(ActivityThread.java:5867)
E/AndroidRuntime( 6271): 	... 14 more
@vicajilau vicajilau added the new issue An issue that hasn't yet been seen from the maintainer label Dec 30, 2024
@vicajilau
Copy link
Author

Bug found, it happens when you don't send the bytes parameter. That means null is sent. PR on its way...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new issue An issue that hasn't yet been seen from the maintainer
Projects
None yet
Development

No branches or pull requests

1 participant