[Solved] Flutter Build Apk Not Working With Image Picker

flutter build apk not working with image picker

In this tutorial, we’ll learn how to solve the issue with Flutter build apk not working with image picker package. We’ll first see the problem, then we’ll solve it using step by step explanation.

Introduction: Flutter Build Not Working With Image Picker Package

I’ve encountered this issue while I was working in a Flutter project. There was a requirement to import pictures using the gallery and camera of an android device. So, I’ve imported the latest image picker package in my Flutter project.

Everything was working perfectly fine but when I tried to build an apk version of my Flutter app then it showed me an error and the build stopped.

It took me a alot of hours to figure out what the problem was. I’ve tried many solutions but none of them worked for me.

Finally, I found the best solution which was changing the version of image picker package.

Let’s now first see what problems we’ll face with the latest image picker package. After that, we’ll apply our solution.

Using Latest Image Picker Package Version(Problem)

Click here to get the latest image picker package from its official site. In my case, the latest package version is given below:

image_picker: ^0.8.5+3

Import it in your project’s puspec.yaml file and run (flutter pub get) in the terminal. See below image:

futter pub get

flutter build apk not working with image picker

Now in the terminal, just write (flutter build apk) and click enter.

flutter build apk

flutter build apk not working with image picker

We can see that it shows an error and the build stopped. Let’s now see what can we do to get rid of Flutter build apk not working with image picker issue.

Using An Old Image Picker Package Version(Solution)

In order to fix Flutter build apk not working with image picker, we’ve to use an old version of image picker package. The version is given below:

image_picker: ^0.7.5+1
We’ve to follow the same above process to install this package and build Flutter apk.
First replace the latest image picker package with this one in the pubspec.yaml file and run (flutter pub get) in the terminal.
After that, run (flutter build apk) in the terminal. If the problem still exists then first run (flutter clean) in the terminal. After that, run (flutter build apk). In my case, it worked and the issue of Flutter build apk not working with image picker was successfully removed. See below image:
flutter build apk issue solved with image picker
We can see that the apk is successfully built. So this is how we can fix the issue of Flutter build apk not working with image picker package.

Click here if you want to learn how to properly build Flutter apk and get the location of apk file.

Conclusion

To conclude this tutorial, hope you now have a complete idea of how to fix the Flutter build apk not working with image picker package. I’d love to have your feedback on this post.

I’d also love to see you visit my other tutorials on Flutter app development and Python programming as well. Thank you for reading this post.

Leave a Comment

Your email address will not be published. Required fields are marked *