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
Related
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!
After upgrade my android os to version 12, my code stopped work, I use flutter plugin tflite_flutter 0.9.0 and I launch tflite in isolation.
It throws this error:
TfLiteGpuDelegate Invoke: GpuDelegate must run on the same thread where it was initialized.
E/tflite (20055): Node number 64 (TfLiteGpuDelegateV2) failed to invoke.
E/flutter (20055): [ERROR:flutter/runtime/dart_isolate.cc(1111)] Unhandled exception:
E/flutter (20055): Bad state: failed precondition
E/flutter (20055): #0 checkState (package:quiver/check.dart:74:5)
E/flutter (20055): #1 Interpreter.invoke (package:tflite_flutter/src/interpreter.dart:150:5)
E/flutter (20055): #2 Interpreter.runForMultipleInputs (package:tflite_flutter/src/interpreter.dart:190:5)
E/flutter (20055): #3 Classifier.predict (package:myai/ai/tflite/mobilenet/object/classifier.dart:179:19)
E/flutter (20055): #4 IsolateHelper.entryPoint (package:myai/ai/helper/isolate_helper.dart:51:30)
My code:
final gpuDelegateV2 = GpuDelegateV2(
options: GpuDelegateOptionsV2(
isPrecisionLossAllowed:true,
inferencePreference:TfLiteGpuInferenceUsage.preferenceSustainSpeed,
inferencePriority1:TfLiteGpuInferencePriority.minMemoryUsage,
inferencePriority2:TfLiteGpuInferencePriority.auto,
inferencePriority3:TfLiteGpuInferencePriority.auto,
)
);
var interpreterOptions = InterpreterOptions()..addDelegate(gpuDelegateV2);
_interpreter = interpreter ??
await Interpreter.fromAsset(
MODEL_FILE_NAME,
options: interpreterOptions
);
Anyone faced such problem? Any suggestions how to fix it?
Is it possible that the error you encounter is
Can not open OpenCL library on this device - dlopen failed: library "libOpenCL.so" not found?
Version 12 requires modules to declare dependencies in the manifest. When targeting Sdk version S you need to add the TFLite dependencies to your manifest. Read the follow relevant comment taken from here.
Note: You can now target Android S+ with targetSdkVersion="S" in your manifest, or targetSdkVersion "S" in your Gradle defaultConfig (API level TBD). In this case, you should merge the contents of AndroidManifestGpu.xml into your Android application's manifest. Without this change, the GPU delegate cannot access OpenCL libraries for acceleration. AGP 4.2.0 or above is required for this to work.
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.
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.
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