Skip to content

Troubleshooting

Miguel Ruivo edited this page Aug 4, 2020 · 28 revisions

Android

πŸ› Issue:

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)

πŸ›  Possible solution:

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.


πŸ› Issue:

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.

πŸ›  Possible solution:

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 he’s own (such as ESExplorer). Those file explorers will may be capable to handle the request but not always will (actually, unfortunately most of times won't) honour 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.


πŸ› Issue:

If for some reason when picking you receive an error telling that permissions are already being request, picker is already active or similar.

πŸ›  Possible solution:

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.


πŸ› Issue:

If your project fails building due to dependencies missing. Typically this happens with import androidx.lifecycle.DefaultLifecycleObserver; being not recognized.

πŸ›  Possible solution:

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.

  1. On your project's android/app/build.gradle change compileSdkVersion and targetSdkVersion to 28

  2. 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:

  1. Create a new app with the same name and dependencies using flutter create;
  2. Carefully copy your source code to the new project picking only the required files, specially inside android/ directory;
  3. Build, and everything should be OK at this point;

πŸ› Issue:

I'm picking a directory through getDirectoryPath() but it throws an error or an empty path.

πŸ›  Possible solution:

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 (/).


iOS

πŸ› Issue:

I can't build for iOS. There are some OBJC symbol errors on Xcode or any other weird errors that prevent build to succeed.

πŸ›  Possible solution:

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.

  1. On project/ios folder, run pod deintegrate && rm Podfile.lock && pod install
  2. On your project folder, run flutter clean
  3. Clear the Xcode derived that by running rm -rf ~/Library/Developer/Xcode/DerivedData
  4. Open the project with Xcode and also clean by doing Cmd + Shift + K
  5. Build with flutter build ios command.

πŸ› Issue:

I have an issue while picking multiple files from Photos app (gallery)

πŸ›  Possible solution:

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.

Clone this wiki locally