getting error when using the dependency in flutter - flutter

when i add dependency to pubspec.yaml files ,in some dependency i get error ,i tried many to resolve it but i can't able to resolve it.
getting this error when using image picker dependency
i tried
flutter clean
restart the pc
reinstall the app
[ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method pickImage on channel plugins.flutter.io/image_picker)

Possible solutions to what might occur:
Pay attention to indentation in your pubspec.yaml file.
Make sure that you don't have any error on dependency version.
Make sure that you run flutter pub get after adding dependency
Probably it is not documented that you have to add following permission to Android manifest file:
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
Sometimes it might be needed to clean cache and run the project again by using flutter clean && flutter run command on terminal.

Related

Flutter app keep sending me this on log when restart 'Local module descriptor class for com.google.android.gms.providerinstaller.dynamite not found.'

i keep getting this error in my app when i debug my app, the error say
W/DynamiteModule( 6570): Local module descriptor class for com.google.android.gms.providerinstaller.dynamite not found.
I/DynamiteModule( 6570): Considering local module com.google.android.gms.providerinstaller.dynamite:0 and remote module com.google.android.gms.providerinstaller.dynamite:0
W/ProviderInstaller( 6570): Failed to load providerinstaller module: No acceptable module com.google.android.gms.providerinstaller.dynamite found. Local version is 0 and remote version is 0.
whenever i restart my flutter app. it keep giving me this error, and when i tried to take data from firestore it didn't gave me any. after i go to other page and go back to the original page. the data load and the error gone.
i've been following some of other relate question and there's no helpful answer for that, this what i've been tried earlier
adding <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> to the AndroidManifest.xml at android > App > main > AndroidManifest.xml
tried to do flutter clean and flutter pub get and still didn't solve the problem.
adding this <uses-permission android:name="android.permission.INTERNET"/> to the AndroidManifest.xml and remove it again and still not solve the problem.
i've been check the pubspec.yaml and do dependencies update and still yet there's no sign of the problem been solve.
debug on emulator, and 2 real device still gave me the same problem.
tried to delete the app on device and built it again, and nope
multiDexEnabled true added to app/build.gradle
yep and the issue still there. and the problem only show up when being first open/run. and after i goes to other, it'll comeback to normal.

shared preferences not working in the background in flutter

i am using shared_preferences: ^2.0.7 with flutter_background_service: ^0.1.5 in flutter
but when call shared preferences give me the error
"Flutter: Unhandled exception: MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences)"
When working in the forground mode, the call is done correctly, this problem occurs only about the call in the background mode.
usually this happens when thirdparty pulgin files are not properly included in build apk , to avoid this try :
flutter clean
flutter pub get
flutter run
this will make sure proper build with required files.
Tip : when adding a new plugin to pubspec.yaml file avoid Hot reload and Hot restart make sure to build apk from scratch so that all required files included in your build.

Flutter build release apk with no sound null safety?

Debug apk works fine, release apk not working..
Tried flutter build apk --no-sound-null-safety it builds release apk but does not works.
Issue Solved!!
Actually, the problem was with 'http' as SSL certificate was not included for the admin panel hence, app showed
Bad state: Insecure HTTP is not allowed by platform error in some devices while it was running in my Mi note4 mobile phone.
Added
android:usesCleartextTraffic="true" line in
AndroidManifest.xml file inside
<manifest <application android:usesCleartextTraffic="true""> </application> </manifest> tag
The ability to mix language versions frees package maintainers to migrate their code, with the knowledge that even legacy users can get new bug fixes and other improvements. However, mixed-version programs don’t get all the advantages that null safety can bring. Read here
Solution
Code for building APK:
flutter build apk --no-sound-null-safety

MissingPluginException(No implementation found for method hasPermissions on channel flutter_audio_recorder)

I use this plugin https://pub.flutter-io.cn/packages/flutter_audio_recorder. I have received the following error
enter image description here
i also write this code to ask the permission
await FlutterAudioRecorder.hasPermissions
and also add the permissions in Androidmenifiest.xml file
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WAKE_LOCK" />
this code also does not ask the user to enable the permission for audio.
please tell me how to fix this issue?
Try to quit Flutter and run again. Also, make sure that you use the command flutter pub get before running your app. If you still get the same error, try flutter clean and run your app.

Problem after generating released apk file in flutter

I generated the released apk file in flutter using android studio. But after generating the file it was installed in real time mobile but not working. It shows host name error in the console. How to resolve this error?
Make sure you added
< uses-permission android:name="android.permission.INTERNET"/>
to your Manifest.xml file android/app/src/main, because flutter do this only for development version
under