-
Notifications
You must be signed in to change notification settings - Fork 673
Troubleshooting
My app is crashing when picking files with a boolean NullPointerException on FilePickerDelegate such as this one:
E/AndroidRuntime( 1459): java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
E/AndroidRuntime( 1459): at com.mr.flutter.plugin.filepicker.FilePickerDelegate$2.run(FilePickerDelegate.java:92)
E/AndroidRuntime( 1459): at java.lang.Thread.run(Thread.java:919)
This issue was reported and widely discussed here as it was triggering a NullPointerException in a place where it never should. After further investigation, it looks like those experiencing this mostly like are running an older Flutter version (probably 1.12 @ stable channel).
The issue is probably fixed by just running flutter upgrade
and making sure that you are running the latest stable, which as of today is at 1.17.3.
I'm using FileType.custom
with some extensions (eg. [csv, jpg]
) and the file explorer doesn't respect it by allowing me picking other types.
When custom extensions are passed, those are translated into MIME types, then, an intent is sent to system requesting a file explorer to handle those and let you pick the files with the given restrictions β typically, the native one.
However, some Android OS versions (custom roms) not always have the native file explorer, neither you can't prevent the user to install a 3rd party on its own (such as ES FileExplorer). Those file explorers will mostly be capable to handle the request but not always will (actually, most of times won't) honor the MIME restrictions as they need to implement that feature and there's no way you can play around it. So, there's no warranty that fileExtensions
will be respected and when you experience this issue, before reporting, try on an official emulator and see if it still happens.
So, because of that, either the package would have to throw an error when the user picked extensions that aren't suppose to, or, the developer can add this extra protection on their side which seems the more appropriate as you can iterate over the picked files and display a custom alert or similar.
If for some reason when picking you receive an error telling that permissions are already being request, picker is already active or similar.
Lately, there have been reports that projects that were started prior to Android V2 embedded, may need to update some properties in order to seamless support updated plugins.
Referring to EdwynZN answer on flutter permission handler plugin, following the official instructions to upgrade pre 1.12 Android projects, seem to fix.
Basically if your Android project MainActivity.java
or kt is using io.flutter.app.FlutterActivity or your AndroidManifest.xml
is using io.flutter.app.FlutterActivity or have
<meta-data
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
android:value="true" />
you'll need to update your Flutter project in order to work with the new Android plugin type system.
If your project fails building due to dependencies missing. Typically this happens with import androidx.lifecycle.DefaultLifecycleObserver;
being not recognized.
Typically this happens because your project isn't fully supporting Android X. Please make sure you have completely migrated to it, by checking the official instructions or you can just check if the requirements below are met.
-
On your project's
android/app/build.gradle
change compileSdkVersion and targetSdkVersion to 28 -
Go to android/gradle.properties file and add the following lines:
android.useAndroidX=true
android.enableJetifier=true
If neither of those worked, you've probably have some conflicting dependencies or have wrongly migrated to V2 embedded support. To fix it, please do the following:
- Create a new app with the same name and dependencies using
flutter create
; - Carefully copy your source code to the new project picking only the required files, specially inside
android/
directory; - Build, and everything should be OK at this point;
I'm picking a directory through getDirectoryPath()
but it throws an error or an empty path.
On Android, there are a few directories that can't be picked to be written "manually", one of those, is the downloads folder which may even return just an empty path (/
).
I can't build for iOS. There are some OBJC symbol errors on Xcode or any other weird errors that prevent build to succeed.
This is often a dependency resolution issue due to existing caching. If you can't build for iOS, regardless of the plugin's version, do the following. It's recommended that you do this every now and then and it also get rid of a lot of used space on your machine.
- On
project/ios
folder, runpod deintegrate && rm Podfile.lock && pod install
- On your project folder, run
flutter clean
- Clear the Xcode derived that by running
rm -rf ~/Library/Developer/Xcode/DerivedData
- Open the project with Xcode and also clean by doing
Cmd + Shift + K
- Build with
flutter build ios
command.
I have an issue while picking multiple files from Photos app (gallery)
This plugin uses DKImagePickerController as sub-dependency for multi picks on Photos app because ImagePickerController
from iOS SDK doesn't allow it. Thus, any issue directly related to it, should be filed on its official repo.