The application works fine when I remove the "Image_picker" dependency.When I add back "shared_preferences" gives an error.
flutter run --release --verbose
This error is displayed when starting the application and when I want to use "shared_preferences".
[+8288 ms] E/flutter (10416): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: MissingPluginException(No implementation found
for method getAll on channel plugins.flutter.io/shared_preferences)
"Image_picke" gives this error.
[ +2 ms] E/flutter (10872):
[+18180 ms] E/flutter (10872): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: PlatformException(already_active, Image picker
is already active, null, null)
[ +3 ms] E/flutter (10872): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:581)
[ +1 ms] E/flutter (10872): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:158)
[ +1 ms] E/flutter (10872): <asynchronous suspension>
[ +2 ms] E/flutter (10872): #2 MethodChannelImagePicker.pickImage
(package:image_picker_platform_interface/src/method_channel/method_channel_image_picker.dart:29)
[ +2 ms] E/flutter (10872): <asynchronous suspension>
[ +1 ms] E/flutter (10872): #3 _PhotoAndNameState.takePicture (package:jokesapp/photoAndName.dart:22)
[ +1 ms] E/flutter (10872): <asynchronous suspension>
[ +2 ms] E/flutter (10872):
The error is fixed if I delete the dependency "Image_picker". But I have to use "Image_picker"
https://github.com/flutter/flutter/issues/40339 Someone mentioned this in this issues. My better suggestion is to use your own channel to pick the image from native instead of using the third-party libraries, because sometimes you may get the plugin issues which will not be resolved and need to be waited until the plugin gets updated. Recently i faced the Permissions issue in flutter where i'm using permission_handler and the image_picker, the permission_handler i have used for microphone access, where as the image_picker will have their own permission checker. So when we include both the libraries in the project only one library will work because of the Override method of OnRequest and OnActivity. The image_picker works for android 10 only in debug mode.
But I could not understand exactly what he was talking about. Since I will publish my application, "image_picker" is a safer choice for me.
I solved this problem days ago. Gradle version became 4.1.0 with new updates."Image_picker" dependency does not work in Gradle 4.1.0 version.Also, when it is in the same project with "shared_preferences" dependency, "shared_preferences" dependency also does not work.After removing "image_picker" from project, "shared_preferences" works correctly.So when we include both the libraries in the project only one library will work because of the Override method of OnRequest and OnActivity.
For more information. #40339
SOLUTION
Sorry, the only solution is to drop the gradle version.
classpath 'com.android.tools.build:gradle:3.5.4'
I made the gradle version 3.5.4 and now everything works fine. After lowering the Gradle version, if you get the NDK error, reduce the NDK version at the same time. #76393