Flutter error on building files in Android Studio - android

I have newly installed Flutter on Android Studio. I had a source code of flutter which I want to open using it. I installed the latest flutter plugin and flutter SDK. But when I try to run the app, it shows me the following error:
Compiler message:
/C:/Flutter%20SDK/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.14.4/lib/src/picture_stream.dart:92:3: Error: The superclass, 'Diagnosticable', has no unnamed constructor that takes no arguments.
PictureStream();
^^^^^^^^^^^^^
/C:/Flutter%20SDK/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.14.4/lib/src/picture_stream.dart:192:16: Error: The superclass, 'Diagnosticable', has no unnamed constructor that takes no arguments.
abstract class PictureStreamCompleter extends Diagnosticable {
^
Compiler message:
/C:/Flutter%20SDK/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.14.4/lib/src/picture_stream.dart:92:3: Error: The superclass, 'Diagnosticable', has no unnamed constructor that takes no arguments.
PictureStream();
^^^^^^^^^^^^^
/C:/Flutter%20SDK/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.14.4/lib/src/picture_stream.dart:192:16: Error: The superclass, 'Diagnosticable', has no unnamed constructor that takes no arguments.
abstract class PictureStreamCompleter extends Diagnosticable {
^
Target kernel_snapshot failed: Exception: Errors during snapshot creation: null
build failed.
FAILURE: Build failed with an exception.
* Where:
Script 'C:\Flutter SDK\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 882
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\Flutter SDK\flutter\bin\flutter.bat'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 23s
Exception: Gradle task assembleDebug failed with exit code 1
I am completely new to this and have no idea where this error is pointing. I have the latest Flutter SDK version: Flutter 1.17.0 and Dart 2.8.1, it's a stable version. My Android Studio version is 3.6.2

Try executing this in your terminal :
flutter pub cache repair
If it doesn't work, deleting the flutter folder, along with the cache folder should do the job.

In my case i solved this problem adding the latest version of flutter svg to pubspec.yaml
Check the link to install latest version: https://pub.dev/packages/flutter_svg#-installing-tab-

Related

Error when trying to run command 'flutter run'

I was trying to run command 'flutter run' Its giving me errors. There are no issues with flutter doctor. I don't know where the error is from, I tried to run this flutter clean, flutter pub cache repair, flutter run. Still the same error.
Warning: You are using these overridden dependencies:
! intl 0.17.0
Running "flutter pub get" in cretello_rentors_plus_1... 34.3s
Using hardware rendering with device sdk gphone x86 arm. If you notice graphics
artifacts, consider enabling software rendering with
"--enable-software-rendering".
Launching lib\main.dart on sdk gphone x86 arm in debug mode...
/C:/src/flutterSDK/flutter/.pub-cache/hosted/pub.dartlang.org/dynamic_theme-1.0.1/lib/dynamic_theme.dart:25:46: Error: Method not found: 'TypeMatcher'.
return context.ancestorStateOfType(const TypeMatcher<DynamicThemeState>());
^^^^^^^^^^^
/C:/src/flutterSDK/flutter/.pub-cache/hosted/pub.dartlang.org/dynamic_theme-1.0.1/lib/dynamic_theme.dart:25:20: Error: The method 'ancestorStateOfType' isn't defined for the class 'BuildContext'.
- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/C:/src/flutterSDK/flutter/packages/flutter/lib/src/widgets/framework.dart').
Try correcting the name to the name of an existing method, or defining a method named 'ancestorStateOfType'.
return context.ancestorStateOfType(const TypeMatcher<DynamicThemeState>());
^^^^^^^^^^^^^^^^^^^
FAILURE: Build failed with an exception.
* Where:
Script 'C:\src\flutterSDK\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1035
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\src\flutterSDK\flutter\bin\flutter.bat'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 43s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 44.8s
Exception: Gradle task assembleDebug failed with exit code 1```
try one of this solutions
———
https://github.com/fluttercommunity/flutter_google_places/issues/140
This issues is due to your flutter versions. If you are copying others code, make sure to first run.
flutter clean
flutter pub get
If this does not work make sure you use the correct versions of the flutter sdk.

Flutter Build Issue

When I try to open the application made with Flutter on the test device, I get the following error. I tried many methods but could not get a successful result. What do you think is the error and how can I resolve it?
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/provider-2.0.1+1/lib/src/provider.dart:179:19: Error: The method 'inheritFromWidgetOfExactType' isn't defined for the class 'BuildContext'.
- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/framework.dart').
Try correcting the name to the name of an existing method, or defining a method named 'inheritFromWidgetOfExactType'.
? context.inheritFromWidgetOfExactType(type) as _Provider<T>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/provider-2.0.1+1/lib/src/provider.dart:180:19: Error: The method 'ancestorInheritedElementForWidgetOfExactType' isn't defined for the class 'BuildContext'.
- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/C:/src/flutter/packages/flutter/lib/src/widgets/framework.dart').
Try correcting the name to the name of an existing method, or defining a method named 'ancestorInheritedElementForWidgetOfExactType'.
: context.ancestorInheritedElementForWidgetOfExactType(type)?.widget
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FAILURE: Build failed with an exception.
* Where:
Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 991
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\src\flutter\bin\flutter.bat'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BU�LD FAILED in 2m 0s
Exception: Gradle task assembleDebug failed with exit code 1
It looks like you're using the version 2.0.1 of the Provider Library.
This version isn't compatible with the newest versions of Flutter, since the inheritFromWidgetOfExactType was deprecated in Flutter 1.12
You have two choices here, either downgrade the version of Flutter you're using to be below 1.12, or upgrade your Provider import to a newer one (I strongly recommend you to pick the second option !)
You should try this.
Yesterday I Just restarted my pc and got this issue. I tried to search for the solution to this problem but nothing works in my case.
Solution
Just delete your flutter folder (Flutter Source) and then reinstall it. Your problem will solve.

Flutter - Error: The language version override has to be the same in the library and its part(s)

I was update my Flutter SDK version from dev channel (1.14.5) to stable channel (2.0.1). My codes was works perfectly but now i get this error. I think the problem is at slide_countdown_clock but im not sure.
lib/Screens/sets4_widget/Countdown.dart:7:6: Error: The language version override has to be the same in the library and its part(s).
part 'package:slide_countdown_clock/clip_digit.dart';
^
lib/Screens/sets4_widget/Countdown.dart:8:6: Error: The language version override has to be the same in the library and its part(s).
part 'package:slide_countdown_clock/digit.dart';
^
lib/Screens/sets4_widget/Countdown.dart:9:6: Error: The language version override has to be the same in the library and its part(s).
part 'package:slide_countdown_clock/slide_direction.dart';
^
FAILURE: Build failed with an exception.
* Where:
Script 'C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 991
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\flutter\bin\flutter.bat'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 13s
Exception: Gradle task assembleDebug failed with exit code 1
^
I also share the lines of code that the error pointed to me below.
part 'package:slide_countdown_clock/clip_digit.dart';
part 'package:slide_countdown_clock/digit.dart';
part 'package:slide_countdown_clock/slide_direction.dart';
those parts are give me error. I tried flutter clean > flutter upgrade > flutter pub upgrade but still no result. Can anyone please help?
slide_countdown_clock, this package does not support Null Safety and Flutter 2.0.1 is a version with null safety.
So, you can't use it on Flutter version 2.0.1. Try to use another pub package that supports Null Safety.
You should not upgrade to Flutter version 2.0.1 until your existing project's dependencies are not supporting Null Safety.
I know this doesn't apply to your case, but I had this error as well and in my case it was due to the fact that I had the library code in the lib folder of the project using it. Just moving it in a different location solved my issue.

Flutter Build failed

While building and running the Flutter mobile application with flutter --version
Flutter 2.0.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision c5a4b4029c (3 days ago) • 2021-03-04 09:47:48 -0800
Engine • revision 40441def69
Tools • Dart 2.12.0
I am getting the below error.
Launching lib/main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...
/Applications/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/chewie-0.9.10/lib/src/chewie_player.dart:83:7: Error: No named parameter with the name 'resizeToAvoidBottomPadding'.
resizeToAvoidBottomPadding: false,
^^^^^^^^^^^^^^^^^^^^^^^^^^
/Applications/Flutter/flutter/packages/flutter/lib/src/material/scaffold.dart:1451:9: Context: Found this candidate, but the arguments don't match.
const Scaffold({
^^^^^^^^
/Applications/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/chewie-0.9.10/lib/src/chewie_player.dart:276:17: Error: The method 'inheritFromWidgetOfExactType' isn't defined for the class 'BuildContext'.
'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/Applications/Flutter/flutter/packages/flutter/lib/src/widgets/framework.dart').
Try correcting the name to the name of an existing method, or defining a method named 'inheritFromWidgetOfExactType'.
context.inheritFromWidgetOfExactType(_ChewieControllerProvider)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/Applications/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/chewie_audio-1.0.0+1/lib/src/chewie_player.dart:101:17: Error: The method 'inheritFromWidgetOfExactType' isn't defined for the class 'BuildContext'.
'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/Applications/Flutter/flutter/packages/flutter/lib/src/widgets/framework.dart').
Try correcting the name to the name of an existing method, or defining a method named 'inheritFromWidgetOfExactType'.
context.inheritFromWidgetOfExactType(_ChewieAudioControllerProvider)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/Applications/Flutter/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_svg-0.18.0/lib/src/picture_provider.dart:50:59: Error: No named parameter with the name 'nullOk'.
context != null ? Localizations.localeOf(context, nullOk: true) : null,
^^^^^^
/Applications/Flutter/flutter/packages/flutter/lib/src/widgets/localizations.dart:413:17: Context: Found this candidate, but the arguments don't match.
static Locale localeOf(BuildContext context) {
^^^^^^^^
FAILURE: Build failed with an exception.
Where:
Script '/Applications/Flutter/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 991
What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
Process 'command '/Applications/Flutter/flutter/bin/flutter'' finished with non-zero exit value 1
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 39s
Exception: Gradle task assembleDebug failed with exit code 1
On running flutter doctor no errors are shown. Based on some references even tried switching the flutter channel to beta, master, and dev but the issue still occurs. With the downgrade of the flutter version as well, I am unable to resolve this. The application was working well before and all of sudden this happened.
Please help me in resolving this. Thanks.
As far as I assume, one of your package causing the problem, I think It's chewie_player.Try using latest version of it, Go to pub dev, and copy the dependence, paste it in .yaml file in place of older dependence.

Error: Type 'TableMetadata' not found | FAILURE: Build failed with an exception

I am new to flutter and I am facing this issue that after cleaning the build (flutter clean) my code stopped working and it is stuck in build failed..
I tried deleting the flutter SDK and doing that process again but still I am getting the same error messages.
I was trying to fix the Firebase login and replaced the 'google-services.json' file and then after these commands flutter [clean build, pub get and pub upgrade] the code is stuck in build.
(this is the error message and the screenshot)
Running Gradle task 'assembleDebug'...
../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_widget_from_html-0.5.1+5/lib/src/widget_factory.dart:60:57: Error: Type 'TableMetadata' not found.
Widget buildTable(BuildMetadata m, TextStyleHtml tsh, TableMetadata data) =>
^^^^^^^^^^^^^
../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_widget_from_html-0.5.1+5/lib/src/internal/layout_grid.dart:7:24: Error: Type 'TableMetadata' not found.
TextStyleHtml tsh, TableMetadata data) {
^^^^^^^^^^^^^
../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_widget_from_html-0.5.1+5/lib/src/widget_factory.dart:60:57: Error: 'TableMetadata' isn't a type.
Widget buildTable(BuildMetadata m, TextStyleHtml tsh, TableMetadata data) =>
^^^^^^^^^^^^^
../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_widget_from_html-0.5.1+5/lib/src/internal/layout_grid.dart:7:24: Error: 'TableMetadata' isn't a type.
TextStyleHtml tsh, TableMetadata data) {
^^^^^^^^^^^^^
FAILURE: Build failed with an exception.
* Where:
Script 'D:\Flutter\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 904
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'D:\Flutter\flutter\bin\flutter.bat'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 6m 10s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 376.2s (!)
Exception: Gradle task assembleDebug failed with exit code 1
I tried to search for this build failed issue but I can't get to fix it.
In your app's pubspec.yaml file look for this line: flutter_widget_from_html and use the version ^ 0.5.1 + 3
Ex: flutter_widget_from_html: ^0.5.1+3
Then click on pub upgrade and run your app
"The easiest fix is to run flutter pub upgrade to make sure both flutter_widget_from_html and flutter_widget_from_html_core is updated together."
Before upgrading pub, you should constrain the newest package version in the pubspec.yaml as flutter_widget_from_html: ^0.5.2
For credit and more info see here

Categories

Resources