I was debugging my project. After some execution, it started showing an error saying that the Dart compiler exited unexpectedly (see screenshot below). I also updated my dart SDK, but nothing happened. I did search on Google, but found nothing that helped.
try this may help
flutter clean
This issue could also happen when you have migrated to Null-Safety. The reason is that when migrating to Null-Safety, all packages need to also be migrated to Null-Safety, thus it will return an error saying:
Error: Cannot run with sound null safety, because the following dependencies
don't support null safety:
Also, it will give you a link for you to reference:
For solutions, see https://dart.dev/go/unsound-null-safety
Unhandled exception:
Bad state: Unsupported Null Safety mode NonNullableByDefaultCompiledMode.Invalid, in null.
Since this issue results in an error, you won't be able to run your project or package unless all packages in your dependencies are null-safety migrated. The dart compiler will end after this.
the Dart compiler exited unexpectedly.
Failed to compile application.
Exited (sigterm)
If you get the issue and you are sure that all packages are up-to-date and that all support Null-Safety, try running flutter clean. This will clear or packages in your project and reinstall them, cache files will also be removed.
Please leave down a comment if you may have any suggestions, or edit this answer if you wish.
I had this problem after adding package golden_toolkit and one golden test I wrote for it. Removing the test file and the dependency from pubspec.yaml and then running flutter clean, flutter pub get fixed it.
In my case flutter clean cant help. My flutter/bin/cache folder was corrupted. Deleting flutter/bin/cache folder and then running command flutter, downloads dart SDK and then setting up the flutter sdk path by giving your flutter folder path in Android Studio -> Preferences -> Languages and Frameworks -> Flutter , solves my problem.
delete flutter/bin/cache then type in terminal flutter clean then flutter run
that's work for me
My case was really strange and I don't know were it comes from, is it VS or Dart
The point is somewhere here where I set my class as the generic of the base class: class MyClass extends MyBaseClass<MyClass> and add an instance to the VS WATCH and set a beark point after the instance creation.
class MyBaseClass<T> {}
class MyClass extends MyBaseClass<MyClass> {
#override
String toString() => "MyClassObject";
}
main() {
MyClass o = MyClass();
print(o); // If you add 'o' to your WATCH items and add a breakpoint here it will crash
}
if you add any packages it can be the problem.
just use
flutter clean
flutter pub get
flutter run
Related
I developed a flutter app on an Ubuntu machine and it works without problems on Android. Now I am trying to run it on iOS from a Mac but when I start debugging, I get several errors like the following:
/opt/flutter/.pub-cache/hosted/pub.dartlang.org/entry-0.0.2_2/ios/Classes/SwiftAnimateInPlugin.swift:4:14: error: invalid redeclaration of 'SwiftEntryPlugin'
public class SwiftEntryPlugin: NSObject, Flutter Plugin {
^
flutter doctor passes for Flutter, Xcode, and Connected device.
Flutter 2.2.0 - channel stable
Tools - Dart 2.13.0
I have checked this question but they are not using Flutter and the answers are not relevant as far as I can tell. What would cause this error and how might I resolve it?
Taking Nisanth Reddy's advice from the comment above and grepping for SwiftEntryPlugin: NSObject my search was narrowed down to 2 files. The files were ./my-app/ios/.symlinks/plugins/entry/ios/Classes/SwiftEntryPlugin.swift and ./my-app/ios/.symlinks/plugins/entry/ios/Classes/SwiftAnimateInPlugin.swift. After some trial and error, it seems like both files are required (the redundant one being required by a particular Flutter package I'm using, I think) but both had the exact same code in them so I removed all the code from one of the files but left the empty file sitting there in the directory and the problem was resolved.
My app was working perfectly and suddenly it started showing me compiler error. Here is the error:
Compiler message:
org-dartlang-debug:synthetic_debug_expression:1:1: Error: Method not found: 'toStringDeep'.
toStringDeep()
^^^^^^^^^^^^
org-dartlang-debug:synthetic_debug_expression:1:1: Error: The method 'toStringDeep' isn't defined for the class 'NumberFormat'.
- 'NumberFormat' is from 'package:intl/intl.dart' ('file:///Users/chandra/flutter/.pub-cache/hosted/pub.dartlang.org/intl-0.15.7/lib/intl.dart').
Try correcting the name to the name of an existing method, or defining a method named 'toStringDeep'.
toStringDeep()
This is a known bug 36091 and 30381 which should be fixed in the next release. The only workaround is to run flutter clean. (Using Android Studios Tools -> Flutter -> Flutter Clean should also work).
It is a hassle to do this every time so I saved it default config which works for any Flutter run.
Run --> Edit Configurations
Select Flutter and then add new configuration of external tool like
Next create tool as shown
Make sure our external tool is checked
Finally, you should have something like
Hit ok and done!!!
Now every time you run a Flutter app, it will clean the build first.
After successfully linting and updating a pod, I updated it in the main project. However, upon cleaning I encountered this issue:
Normally this is simple to resolve (go to Build Settings and set the Swift Language Version -- however, this error is occurring on the Resource-Target, which doesn't have that setting...making it very strange that I am running into this error.
I've figured out how to resolve this.
The Resource-Target includes a xcdatamodel. I needed to change the Code Generation to Objective-C rather than Swift. This was hard to find especially since the pod lint step did not catch this or give any warning.
I found this answer via: https://github.com/CocoaPods/CocoaPods/issues/7950 -- even though this issue doesn't seem to be exactly the same as this one, but it is related.
I have a project that was building fine a few days ago, since then I haven't changed my dart-sdk or any library dependencies or update dart editor to my knowledge, I just made a very small change to one of my polymer elements to use paper-buttons instead of standard buttons, the change can be seen here
Now when I run pub build I get the following errors, and I have no idea why, if I look in packages polymer/polymer.dart does exist and dart editor doesn't show any warnings in the project. similarly if I undo my latest changes and go back to my last working version I still get this exact same error, so I'm not sure how to debug this, any hints would be much appreciated.
Can't read 'package:polymer/polymer.dart' (Could not find asset polymer|lib/polymer.dart.).
import 'package:polymer/polymer.dart';
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
For such weird problems it's often a good idea to try pub cache repair.
I found an open issue with the same error message: http://dartbug.com/20285
Check if pub get or pub upgrade show some warnings, errors, ...
I'm going through the "targets" (tutorials) at dartlang.org. I'm at Target 6: Get Started with Web UI and have run into an error at step #1 under the section "Set up background compilation in Dart Editor".
Could someone explain why this error is happening, or what I could do to resolve it? The error is below.
Error setting breakpoint at 'main': 'package:logging/logging.dart':
Error: line 250 pos 24: wrong number of type arguments in type 'Comparable'
class Level implements Comparable<Level> {
^
I have not changed anything in any logging package, nor messed with any Comparable class. What gives?
Take a look at this question. I actually don't know why is this happening(If someone of the dart dev team is reading this, please, explain us :D), but it seems that they changed the Comparable interface structure in M3, and forgot to update the logging package ;)
To solve your problem, go to the "logging.dart" file and make this change:
FROM:
class Level implements Comparable<Level> {
TO:
class Level implements Comparable {
This is probably related to incompatibilities between the version of the SDK you are running and the version of web_ui. If you have the most recent version of both, they work together. If you don't want to use the most recent versions, then you have to explicitly manage the versions in your pubspec.yaml file.
I'm using Dart Editor version: 0.4.0_r18915 and web_ui version: 0.4.0
and it works fine.
Try getting the most recent version of Dart Editor, remove the pubspec.lock file, and run pub install again.
Meanwhile, I will figure out how to strengthen the language in the tutorial about managing versions.
Hope this helps.
mem