I'm just getting into Flutter, I tried to run the default flutter app on Visual Studio Code but it won't run here is the error code:
Crash when compiling null,
at character offset null:
Null check operator used on a null value
#0 InferableTypeBuilderMixin.type (package:front_end/src/fasta/builder/type_builder.dart:392:29)
#1 InferableTypeBuilder.inferType (package:front_end/src/fasta/builder/omitted_type_builder.dart:155:12)
#2 SourceLoader.performTopLevelInference (package:front_end/src/fasta/source/source_loader.dart:2358:19)
#3 KernelTarget.buildOutlines.<anonymous closure> (package:front_end/src/fasta/kernel/kernel_target.dart:532:14)
<asynchronous suspension>
#4 withCrashReporting (package:front_end/src/fasta/crash.dart:122:12)
<asynchronous suspension>
#5 _buildInternal (package:front_end/src/kernel_generator_impl.dart:139:7)
<asynchronous suspension>
#6 withCrashReporting (package:front_end/src/fasta/crash.dart:122:12)
<asynchronous suspension>
#7 generateKernel.<anonymous closure> (package:front_end/src/kernel_generator_impl.dart:47:12)
<asynchronous suspension>
#8 generateKernel (package:front_end/src/kernel_generator_impl.dart:46:10)
<asynchronous suspension>
#9 kernelForModule (package:front_end/src/api_prototype/kernel_generator.dart:100:11)
<asynchronous suspension>
#10 SingleShotCompilerWrapper.compileInternal (file:///C:/b/s/w/ir/cache/builder/sdk/pkg/vm/bin/kernel_service.dart:412:11)
<asynchronous suspension>
#11 Compiler.compile.<anonymous closure> (file:///C:/b/s/w/ir/cache/builder/sdk/pkg/vm/bin/kernel_service.dart:221:45)
<asynchronous suspension>
#12 _processLoadRequest (file:///C:/b/s/w/ir/cache/builder/sdk/pkg/vm/bin/kernel_service.dart:914:37)
<asynchronous suspension>
#0 InferableTypeBuilderMixin.type (package:front_end/src/fasta/builder/type_builder.dart:392:29)
#1 InferableTypeBuilder.inferType (package:front_end/src/fasta/builder/omitted_type_builder.dart:155:12)
#2 SourceLoader.performTopLevelInference (package:front_end/src/fasta/source/source_loader.dart:2358:19)
#3 KernelTarget.buildOutlines.<anonymous closure> (package:front_end/src/fasta/kernel/kernel_target.dart:532:14)
<asynchronous suspension>
#4 withCrashReporting (package:front_end/src/fasta/crash.dart:122:12)
<asynchronous suspension>
#5 _buildInternal (package:front_end/src/kernel_generator_impl.dart:139:7)
<asynchronous suspension>
#6 withCrashReporting (package:front_end/src/fasta/crash.dart:122:12)
<asynchronous suspension>
#7 generateKernel.<anonymous closure> (package:front_end/src/kernel_generator_impl.dart:47:12)
<asynchronous suspension>
#8 generateKernel (package:front_end/src/kernel_generator_impl.dart:46:10)
<asynchronous suspension>
#9 kernelForModule (package:front_end/src/api_prototype/kernel_generator.dart:100:11)
<asynchronous suspension>
#10 SingleShotCompilerWrapper.compileInternal (file:///C:/b/s/w/ir/cache/builder/sdk/pkg/vm/bin/kernel_service.dart:412:11)
<asynchronous suspension>
#11 Compiler.compile.<anonymous closure> (file:///C:/b/s/w/ir/cache/builder/sdk/pkg/vm/bin/kernel_service.dart:221:45)
<asynchronous suspension>
#12 _processLoadRequest (file:///C:/b/s/w/ir/cache/builder/sdk/pkg/vm/bin/kernel_service.dart:914:37)
<asynchronous suspension
I can run the code on Android Studio IDE but not on VS Code.
There are no problems with flutter doctor, I have both flutter and dart extensions installed on VS Code.
It looks like to be a problem after the 2.0 update dart where the null safety it's not allowing you run your code with null variables, but I don't know where is this variable and I'm facing this same problem by days
I solved this problem man.
First I moved my application, that I created through the 'flutter create' code in my prompt, from C disk to D disk because I didn't have to much space on disk, after that I run the main() file in my Android Studio and then in the Visual Studio Code and it work well
Try to do it, maybe it will work for you to
Best Regards!
I tried running the flutter project with the run and debug icon in VScode with an internet connection. Also check your flutter licenses with 'flutter doctor --android-licenses'. I hope that will fix your problem.
I have this error in my dart package. I created dart package with very_good_cli. I can't run my tests from vscode. It crashes with the same log.
If I run the tests with flutter command in the terminal, it works. With dart command, it doesn't work.
I think the problem is, vscode tries to run with dart command and since project has the flutter packages, something about flutter is null there.
Solution is, creating new Flutter project if you create a dart project like me or find a way to tell vscode to run with Flutter.
I've fixed by removing test package and adding flutter_test package.
Related
I use audioplayers https://pub.dev/packages/audioplayers 3.0.1 under Windows and native Android.
Under Android everything works perfectly fine but I have issues under windows.
What works: I can play my audio (mp3) file as often as I want. (Windows and Android)
What doesn't work: If I do a Hot Restart and I again want to play the exact same audio file it results in the following error. (ONLY on Windows)
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: FileSystemException: Cannot open file, path = 'C:\Users\<mypath>.mp3' (OS Error: Der Prozess kann nicht auf die Datei zugreifen, da sie von einem anderen Prozess verwendet wird.
, errno = 32)
#0 _File.open.<anonymous closure> (dart:io/file_impl.dart:356:9)
<asynchronous suspension>
#1 AudioCache.fetchToMemory (package:audioplayers/src/audio_cache.dart:80:5)
<asynchronous suspension>
#2 AudioCache.load (package:audioplayers/src/audio_cache.dart:101:31)
<asynchronous suspension>
#3 AudioPlayer.setSourceAsset (package:audioplayers/src/audioplayer.dart:249:17)
<asynchronous suspension>
#4 AudioPlayer.play (package:audioplayers/src/audioplayer.dart:131:5)
<asynchronous suspension>
I use the player like that _player.play(AssetSource('<file>.mp3'));
Additionally I do dispose _player when the widget is disposed. (gets called - verified with log output)
Am I using the player in a wrong way?
Does Hot Reload do something special I didn't know until now?
Since it is not possible to properly dispose the previous players in hot reload and windows only allows one process to read the file at once this is currently not possible, you can read more about it here.
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!
I have a couple of directories that need to be created if they do not exist on the app's first run. These directories have to be created within the application's support directories. I do not need to use external directories for this app. So, I am sure I do not need to add any permissions for the app in the application manifest for accessing external storage directories. Here is my code in the main() function:
Future<void> main() async {
//This line is needed to use the main function as a Future
WidgetsFlutterBinding.ensureInitialized();
Directory directory = await getApplicationSupportDirectory();
//Create downloads paths if they do not exist
Directory literatureDirectory = Directory("${directory.path}/downloads/literature");
Directory audioLecturesDirectory = Directory("${directory.path}/downloads/audioLectures");
if (!(await literatureDirectory.exists())) {
Directory literatureNewDirectory = await literatureDirectory.create();
}
if (!(await audioLecturesDirectory.exists())) {
Directory audioLecturesNewDirectory = await audioLecturesDirectory.create();
}
runApp(ULTApp());
}
I am using a Samsung mobile device which was recently upgraded to Android 11 (One UI 3). While developing my app, I had to uninstall and re-install it. Whenever I try to re-install it, I get the following error:
E/flutter (22527): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: FileSystemException: Creation failed, path = '/data/user/0/com.example.app_name/files/downloads/literature' (OS Error: No such file or directory, errno = 2)
E/flutter (22527): #0 _Directory.create.<anonymous closure> (dart:io/directory_impl.dart:117:11)
E/flutter (22527): #1 _rootRunUnary (dart:async/zone.dart:1436:47)
E/flutter (22527): #2 _CustomZone.runUnary (dart:async/zone.dart:1335:19)
E/flutter (22527): <asynchronous suspension>
E/flutter (22527): #3 main (package:app_name/main.dart:24:40)
E/flutter (22527): <asynchronous suspension>
E/flutter (22527):
What should I do to fix the error? Thanks
I am new to IOS. I followed the guide and ran the code running on Android on IOS.
But in the log appears
021-02-18 13:02:42.035498+0900 Runner[449:77215] Metal API Validation Enabled
2021-02-18 13:02:42.128775+0900 Runner[449:77215] Configuring the default Firebase app...
2021-02-18 13:02:42.129033+0900 Runner[449:77424] 6.33.0 - [Firebase/Core][I-COR000004] App with name __FIRAPP_DEFAULT does not exist.
2021-02-18 13:02:42.132427+0900 Runner[449:77215] Configured the default Firebase app __FIRAPP_DEFAULT.
2021-02-18 13:02:42.174670+0900 Runner[449:77440] flutter: Observatory listening on http://127.0.0.1:51553/bOh9A8fqOm4=/
2021-02-18 13:02:42.506046+0900 Runner[449:77425] 6.33.0 - <AppMeasurement>[I-ACS025027] Deferring to Google Analytics for Firebase for event data collection.
2021-02-18 13:02:42.627177+0900 Runner[449:77215] WF: === Starting WebFilter logging for process Runner
2021-02-18 13:02:42.627226+0900 Runner[449:77215] WF: _userSettingsForUser mobile: {
filterBlacklist = (
);
filterWhitelist = (
);
restrictWeb = 1;
useContentFilter = 0;
useContentFilterOverrides = 0;
whitelistEnabled = 0;
}
2021-02-18 13:02:42.627266+0900 Runner[449:77215] WF: _WebFilterIsActive returning: NO
2021-02-18 13:02:42.672715+0900 Runner[449:77429] [VERBOSE-2:ui_dart_state.cc(177)] Unhandled Exception: MissingPluginException(No implementation found for method addFlags on channel flutter_windowmanager)
#0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:157:7)
<asynchronous suspension>
#1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:332:12)
#2 FlutterWindowManager.addFlags (package:flutter_windowmanager/flutter_windowmanager.dart:44:27)
#3 main (package:k_leetory/main.dart:14:30)
<asynchronous suspension>
#4 _runMainZoned.<anonymous closure>.<anonymous closure> (dart:ui/hooks.dart:231:25)
#5 _rootRun (dart:async/zone.dart:1190:13)
#6 _CustomZone.run (dart:async/zone.dart:1093:19)
#7 _runZoned (dart:async/zone.dart:1630:10)
#8 runZonedGuarded (dart:async/zone.dart:1618:12)
#9 _runMainZoned.<anonymous closure> (dart:ui/hooks.dart:223:5)
#10 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:301:19)
#11 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
2021-02-18 13:05:02.684451+0900 Runner[449:77432] [VERBOSE-2:profiler_metrics_ios.mm(184)] Error retrieving thread information: (ipc/send) invalid destination port
2021-02-18 13:10:21.957514+0900 Runner[449:77432] [VERBOSE-2:profiler_metrics_ios.mm(184)] Error retrieving thread information: (ipc/send) invalid destination port
I bother this part "App with name __FIRAPP_DEFAULT does not exist."
GoogleService-info.plist and info.plist are perfect. When I made an ios app in firebase, I couldn't do the same with the flutter package name. Because when setting up the flutter android project. I put it underscore in the name and this worked fine. However, the ios app was made differently because underscore is prohibited when you put the package name.
the weird thing is it is keep showing only white screen
So my question is if android flutter name and ios flutter name are different, will this be a problem in firebase?
Yes both the package name different in Android & ios will work fine in firebase , because Android and ios will have different GoogleService and GoogleService Info.plist
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