-
Notifications
You must be signed in to change notification settings - Fork 675
Troubleshooting
My app doesn't build in release mode.
Please, refer to #545 where there is a long discussion regarding this, specially to this comment where you might find a solution.
You're getting something like:
The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve the incompatibility.
Building plugin file_picker...
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'file_picker'.
SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.
This is likely to some badly migrated code from a project that is probably old or needs to be fully migrated to Android X support. You can refer to this official guide or search for issues on this repo regarding this and you'll find a few with different solutions (because people have different versions). One that is quite detailed can be found here.
Please, don't open issues based on compiling incompatibility issues, since there are a lot of similar answered on the repo and you can easily find a solution.
Build is failing with unexpected element <queries> found in <manifest>
.
This is because <queries>
tag was introduced with new package visibility options for Android 11 and upwards (SDK 30+). Because of that, you need to update your build.gradle with a version that includes this changes. Below is a list of supported gradle options.
- 3.3.3
- 3.4.3
- 3.5.4
- 3.6.4
- 4.0.1
Don't forget to update your ditributionUrl
in your gradle-wrapper.properties as well. For example, for gradle 4.0.1, you should have:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
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.
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 steps.
Note: It's recommended that you do this every now and then and it also gets 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 data 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.
I can't pick files of a custom file type (e.g. db
, OPML
, etc.). Exception: PlatformException(FilePicker, Unsupported filter. Make sure that you are only using the extension without the dot, (ie., jpg instead of .jpg). This could also have happened because you are using an unsupported file extension. If the problem persists, you may want to consider using FileType.all instead., null, null)
This issue might be related to the iOS file management. To get it working with non-natively handled file types, you must declare a uniform type identifier.
Example to allow picking files with the file extension OPML
:
Add these lines in your Info.plist
file:
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeIdentifier</key>
<string>podcast.opml</string>
<key>UTTypeConformsTo</key>
<array>
<string>public.xml</string>
</array>
<key>UTTypeDescription</key>
<string>OPML ( Outline Processor Markup Language) is an XML format for outlines.</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>opml</string>
</array>
</dict>
</dict>
</array>
-
UTTypeIdentifier value will be the value you use in your Flutter core. It seems that the value MUST follow the reverse-DNS format (a single segment value like
opml
doesn't work). - public.filename-extension is an array of file extensions matching the file type that shall be picked.
Thank you @Chralu for providing this solution.