Flutter: Missing Plugin Exception Raised when running release builds of android app - android

Issue
I am currently working on an app which uses multiple packages.
The app works like a charm in both debug and profile modes. But when I get the release build and run it, some features do not work.
The reason is a couple of the plugins are not working as intended. This is what I get in the debug console :
E/flutter (14180): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences)
E/flutter (14180):
E/flutter (14180): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences)
Another case during the same run
E/flutter (14180): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: MissingPluginException(No implementation found for method getStorageDirectory on channel plugins.flutter.io/path_provider)
E/flutter (14180): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:157)
E/flutter (14180): <asynchronous suspension>
E/flutter (14180): #1 getExternalStorageDirectory (package:path_provider/path_provider.dart:120)
E/flutter (14180): <asynchronous suspension>
E/flutter (14180): #2 ChatScreenState._init (package:pryzcrybdoctor/Screens/Chats/chat.dart:716)
E/flutter (14180): <asynchronous suspension>
E/flutter (14180): #3 ChatScreenState._prepare (package:pryzcrybdoctor/Screens/Chats/chat.dart:736)
E/flutter (14180): <asynchronous suspension>
I have not used path_provider in my app, it is a transitive dep from a plugin cached_network_image
I got the same exception with permission_handler plugin in this same app, but I removed it to check if permission handler was the issue, but now I can't access camera.
The thing that gets me confused is that all these issues only arise in the release mode. Everything works perfectly in debug and release.
Some weird things I noticed...
It seems that some plugin or plugins are still using the "non AndroidX" support libraries. This is because I have to go through the "build debug then build profile and finally then release" cycle to get the release version built. I've read once that this is when Jetifier is working on some plugins that have not fully migrated. So my best guess is that the issue is with some plugin not fully migrated.
What I have tried so far..
Rebuilding the app multiple times.
flutter clean and then flutter build
flutter pub upgrade
Build using android studio.
Migrate to AndroidX using android studio.
Please let me know if you need more info or logs. Thank you for your time.

Got the solution to this issue from a Flutter GitHub issue.
Just keeping androidx.lifecycle.DefaultLifecycleObserver is enough.
Add the below line to app/proguard-rules.pro:
-keep class androidx.lifecycle.DefaultLifecycleObserver

Related

Flutter Google Sign In error after selecting User Id: PlatformException(sign_in_failed, v1.b: 10: , null, null)

I'm currently developing a Flutter Application for android and the web. However, the google sign-in feature is not working in the release mode or when you install an APK. It does work in Debug and Profile modes. I've tried numerous solutions, including changing the version dependencies of all firebase packages and the Google sign-in package. Updated Gradle, fixed the warning for "JAR files in the classpath should have the same version" and tried a few possible logic changes in the Authentication service code. Although the latter hardly seems to be the problem because the code is working in Debug mode and it was also previously working smoothly (in all modes).
I should mention the fact that I have added both SHA certificates (SHA 1 and SHA 256) from my laptop and also from the play store to make it ready for publishing but it didn't change anything. I also tried removing the Playstore SHA certificates but it doesn't help the problem either.
The error appears after the user clicks on the "Sign In with Google" Button and selects their google account. Below is the exact error I am facing (apart from Google Sign in other authentication services work).
E/flutter (13968): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: PlatformException(sign_in_failed, v1.b: 10: , null, null)
E/flutter (13968): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:607)
E/flutter (13968): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:167)
E/flutter (13968): <asynchronous suspension>
E/flutter (13968): #2 MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:367)
E/flutter (13968): <asynchronous suspension>
E/flutter (13968): #3 GoogleSignIn._callMethod (package:google_sign_in/google_sign_in.dart:266)
E/flutter (13968): <asynchronous suspension>
E/flutter (13968): #4 GoogleSignIn.signIn.isCanceled (package:google_sign_in/google_sign_in.dart:399)
E/flutter (13968): <asynchronous suspension>
E/flutter (13968):
These are the version numbers of all my flutterfire packages and also google sign in:
cloud_firestore: ^3.3.0
firebase_auth: ^3.5.1
firebase_core: ^1.20.1
firebase_messaging: ^12.0.0
firebase_storage: ^10.2.18
google_sign_in: ^5.4.0
firebase_analytics: ^9.2.1
NOTE: There is also a web version of the app, that is running fine in all run modes.
I would really appreciate any inputs on this problem! Thank you.
EDIT: Figured it out. Your release and debug SHA keys are different. First of all, add your debug SHA keys to firebase if it still doesn't work, add your release SHA key to firebase. Hope it will work!

Unhandled Exception: MissingPluginException(No implemen tation found for method login on channel app.meedu/flutter_facebook_auth)

I'm getting the following error when I'm tring to sign in with facebook on android device by my flutter app :
[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: MissingPluginException(No implementation found for method login on channel app.meedu/flutter_facebook_auth)
E/flutter (29705): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:175:7)
E/flutter (29705):
E/flutter (29705): #1 FacebookAuthPlatformImplementation.login (package:flutter_facebook_auth_platform_interface/src/facebook_auth_implementation.dart:34:22)
E/flutter (29705):
You have to restart your app.
Flutter has to inject plugin dependencies into the platform-specific parts of your app, hot restart/hot reload is not enough to trigger the injection. Check this issue for more.
Close the app and execute flutter run command.
Stop the iPhone / Android app.
Re-run application & make sure you did flutter pub get
It's work for me but Let me know if it's not work for you.

using Agora - PlatformException(7, not initialized, null, null)

E/flutter (31727): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: PlatformException(7, not initialized, null, null)
E/flutter (31727): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:607:7)
E/flutter (31727): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:167:18)
E/flutter (31727): <asynchronous suspension>
I am using Agora for Flutter for video broadcasting.
I am getting above exceptions when I leave channel and destroy rtc engine. Any hints to fix this? There are no logs suggesting reason for the error.
here:
const ErrorCode(7)
NotReady → const ErrorCode
The SDK module is not ready. Possible
solutions:
Check the audio device.
Check the completeness of the app.
Re-initialize the SDK.
You may check your code about the engine's create.
The error code 7 occurs when the SDK fails to initialize. Most commonly the error can be due to an incorrect APP ID or missing/expired token.

Flutter and android studio error: Google Play Store is missing

I am getting this error while doing google Authentication using firebase. When I run my app, Buffering comes while clicking on google button.
name: google_signin_example
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
# google sign in
firebase_auth: ^1.4.1
google_sign_in: ^5.0.4
firebase_core: ^1.3.0
# state management
provider: 5.0.0
# icon of google
font_awesome_flutter: 9.1.0
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
this is the pub spec.yaml file.
Error:
Launching lib/main.dart on Android SDK built for arm64 in debug mode...
Running Gradle task 'assembleDebug'...
✓ Built build/app/outputs/flutter-apk/app-debug.apk.
Installing build/app/outputs/flutter-apk/app.apk...
Debug service listening on ws://127.0.0.1:52271/JcyHJ3SiTHE=/ws
Syncing files to device Android SDK built for arm64...
W/GooglePlayServicesUtil( 2685): Google Play Store is missing.
W/GooglePlayServicesUtil( 2685): Google Play Store is missing.
W/DynamiteModule( 2685): Local module descriptor class for com.google.android.gms.auth.api.fallback not found.
E/flutter ( 2685): [ERROR:flutter/lib/ui/ui_dart_state.cc(213)] Unhandled Exception: PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 12500: , null, null)
E/flutter ( 2685): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:597:7)
E/flutter ( 2685): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:156:18)
E/flutter ( 2685): <asynchronous suspension>
E/flutter ( 2685): #2 MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:356:43)
E/flutter ( 2685): <asynchronous suspension>
E/flutter ( 2685): #3 GoogleSignIn._callMethod (package:google_sign_in/google_sign_in.dart:235:30)
E/flutter ( 2685): <asynchronous suspension>
E/flutter ( 2685): #4 GoogleSignIn.signIn.isCanceled (package:google_sign_in/google_sign_in.dart)
E/flutter ( 2685): <asynchronous suspension>
E/flutter ( 2685):
I solved this error by creating a new virtual device that implements the Google Play Store services (It is needed for Google Login).
Open Android Studio > AVD Manager > Create Virtual Device
Choose a device that implements the Play Store, like shown in the following image:
Screenshoot of Virtual device with Google Play Services included
If it doesn't work, you could try to test the feature using a Virtual Device using the "API 29" (Android 10).
Hope it was helpful!

lib/home.dart:2:8: Error: Not found: 'dart:html'

I am new here and facing issues with the Android studio. I try to run main.dart (both ios and android) and get this warning message
** BUILD FAILED **
↳
Invalid depfile: /Users/przemek/AndroidStudioProjects/get_stared_app/.dart_tool/flutter_build/a0939d4e94e10e87373caa81ce1cf2b7/kernel_snapshot.d
Invalid depfile: /Users/przemek/AndroidStudioProjects/get_stared_app/.dart_tool/flutter_build/a0939d4e94e10e87373caa81ce1cf2b7/kernel_snapshot.d
Invalid depfile: /Users/przemek/AndroidStudioProjects/get_stared_app/.dart_tool/flutter_build/a0939d4e94e10e87373caa81ce1cf2b7/kernel_snapshot.d
Invalid depfile: /Users/przemek/AndroidStudioProjects/get_stared_app/.dart_tool/flutter_build/a0939d4e94e10e87373caa81ce1cf2b7/kernel_snapshot.d
lib/home.dart:2:8: Error: Not found: 'dart:html'
import "dart:html";
^
Unhandled exception:
FileSystemException(uri=org-dartlang-untranslatable-uri:dart%3Ahtml; message=StandardFileSystem only supports file:* and data:* URIs)
#0 StandardFileSystem.entityForUri (package:front_end/src/api_prototype/standard_file_system.dart:33:7)
#1 asFileUri (package:vm/kernel_front_end.dart:659:37)
#2 writeDepfile (package:vm/kernel_front_end.dart:853:21)
<asynchronous suspension>
#3 FrontendCompiler.compile (package:frontend_server/frontend_server.dart:574:15)
<asynchronous suspension>
#4 _FlutterFrontendCompiler.compile (package:flutter_frontend_server/server.dart:43:22)
#5 starter (package:flutter_frontend_server/server.dart:182:27)
#6 main (file:///b/s/w/ir/cache/builder/src/flutter/flutter_frontend_server/bin/starter.dart:9:30)
#7 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:299:32)
#8 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
Command PhaseScriptExecution failed with a nonzero exit code
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description
warning: Capabilities for Signing & Capabilities may not function correctly because its entitlements use a placeholder team ID. To resolve this, select a development team in the Runner editor. (in target 'Runner' from project 'Runner')```
What should I do to fix it? Many thanks for the help in the advance. I updated my Andorid studio this morning and since that time I have this issue
Try replacing dart:html with dart:io at the top of your main.dart file.
The accepted answer does not always help. Sometimes the use of universal_html is more suitable. Just install the latest package and use the import as:
import 'package:universal_html/html.dart' as html;
the error can be due also to the import of these two if they are not used
import 'dart:html';
import 'dart:ui';
delete these imports and save

Categories

Resources