Flutter Build Issue - android

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.

Related

Issue on building flutter apk with flutter_tts dependency

I was building a flutter app in a Windows machine and I stopped working on it for several months, after that I now get issues on running the app. It shows those two errors:
FAILURE: Build completed with 2 failures.
1: Task failed with an exception.
Where:
Build file 'C:\Users\okeyr\AppData\Local\Pub\Cache\hosted\pub.dev\flutter_tts-3.6.3\android\build.gradle' line: 31
What went wrong:
A problem occurred evaluating project ':flutter_tts'.
org/gradle/api/services/BuildService
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.
==============================================================================
2: Task failed with an exception.
Where:
Script 'C:\Program Files\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 463
What went wrong:
A problem occurred configuring project ':flutter_tts'.
Failed to notify project evaluation listener.
Cannot invoke method substring() on null object
compileSdkVersion is not specified.
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
Flutter doctor shows everything fine except:
[X] Visual Studio - develop for Windows
X Visual Studio not installed; this is necessary for Windows development.
Download at https://visualstudio.microsoft.com/downloads/.
Please install the "Desktop development with C++" workload, including all of its default components
But I don't think the issue is related with that.
I've I look in depth at failure number 1. I have check the file that gives the error and I found that in line 31:
apply plugin: 'kotlin-android'
So I just went to the file and deleted all the entries related with kotlin, because I am not using Kotlin (I guess).
Then if I rerun the app it now shows another error (related with tts again), but doesn't show the previous ones (not sure if I've moved forward or backwards)
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
C:\Users\okeyr\AndroidStudioProjects\fluttertestapp\android\app\src\main\java\io\flutter\plugins\GeneratedPluginRegistrant.java:24: error: cannot find symbol
flutterEngine.getPlugins().add(new com.tundralabs.fluttertts.FlutterTtsPlugin());
^
symbol: class FlutterTtsPlugin
location: package com.tundralabs.fluttertts
1 error
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
Compilation failed; see the compiler error output for details.
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 16s
Exception: Gradle task assembleDebug failed with exit code 1
After doing a search I found many people with that similar issue (even though none was related to tts plugin) which had adressed it with a flutter pub cache repair or a flutter clean. However, a flutter clean gives me no changes and error persists and when I have executed flutter pub cache repair it had shown:
Failed to repair flutter_tts 3.6.3. Error:
Pub failed to delete entry because it was in use by another process.
This may be caused by a virus scanner or having a file
in the directory open in another application.
Reinstalled 29 packages.
Failed to reinstall 1 package:
flutter_tts 3.6.3
pub finished with exit code 69
Now, if I rerun the code it gives me new error:
The plugin flutter_tts doesn't have a main class defined in C:\Users\okeyr\AppData\Local\Pub\Cache\hosted\pub.dev\flutter_tts-3.6.3\android\src\main\java\com\tundralabs\fluttertts\FlutterTtsPlugin.java or C:\Users\okeyr\AppData\Local\Pub\Cache\hosted\pub.dev\flutter_tts-3.6.3\android\src\main\kotlin\com\tundralabs\fluttertts\FlutterTtsPlugin.kt. This is likely to due to an incorrect androidPackage: com.tundralabs.fluttertts or mainClass entry in the plugin's pubspec.yaml.
If you are the author of this plugin, fix the androidPackage entry or move the main class to any of locations used above. Otherwise, please contact the author of this plugin and consider using a different plugin in the meanwhile.
This error also appears when running pub get or pug upgrade. But if I run pub outdated it gives me that:
Showing outdated packages.
[*] indicates versions that are not the latest available.
Package Name Current Upgradable Resolvable Latest
direct dependencies: all up-to-date.
transitive dependencies:
characters *1.2.1 *1.2.1 *1.2.1 1.3.0
collection *1.17.0 *1.17.0 *1.17.0 1.17.1
js *0.6.5 *0.6.5 *0.6.5 0.6.7
meta *1.8.0 *1.8.0 *1.8.0 1.9.0
path *1.8.2 *1.8.2 *1.8.2 1.8.3
transitive dev_dependencies:
matcher *0.12.13 *0.12.13 *0.12.13 0.12.14
test_api *0.4.16 *0.4.16 *0.4.16 0.4.18
all dependencies are up-to-date.
Process finished with exit code 0
I can't see any dependency related with tts.
Now here I am stucked in that error, I don't know how to proceed. If there is someone who could help me see the light I'd be grateful. Thanks in advance.
I am trying to run the code but it seems tts package is not well defined, anyone that could bring me some help?

isn't defined for the class 'BuildContext

How to solve this problem
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/chewie-0.9.10/lib/src/chewie_player.dar
t:276:17: Error: The method 'inheritFromWidgetOfExactType' isn't defined for the class 'Bu
ildContext'.
- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/C:/src/flutter/p
ackages/flutter/lib/src/widgets/framework.dart').
Try correcting the name to the name of an existing method, or defining a method named 'inh
eritFromWidgetOfExactType'.
context.inheritFromWidgetOfExactType(_ChewieControllerProvider)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/chewie_audio-1.0.0+1/lib/src/chewie_pla
yer.dart:101:17: Error: The method 'inheritFromWidgetOfExactType' isn't defined for the cl
ass 'BuildContext'.
- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('/C:/src/flutter/p
ackages/flutter/lib/src/widgets/framework.dart').
Try correcting the name to the name of an existing method, or defining a method named 'inh
eritFromWidgetOfExactType'.
context.inheritFromWidgetOfExactType(_ChewieAudioControllerProvider)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^FAILURE: Build failed with an exception.
Where:
Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1035
What went wrong:
Execution failed for task ':app:compileFlutterBuildRelease'.
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
BUILD FAILED in 1m 56s
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done 118.6s
Gradle task assembleRelease failed with exit code 1
It seems like you're using an old version of chewie. 0.9.10 is supporting an older version of Flutter. In recent versions of Flutter, inheritFromWidgetOfExactType is deprecated in favor of dependOnInheritedWidgetOfExactType. This issue was fixed in version 0.10.4 of chewie.
Upgrade the version number in your pubspec.yaml. For example to the latest version:
chewie: ^1.2.2

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 Cannot Compile Due to Source Code Error [duplicate]

This question already has answers here:
flutter run -> Error: No named parameter with the name 'keyboardDismissBehavior'
(4 answers)
Closed 2 years ago.
When I try to run the app on the emulator I get this error saying there is something wrong with the... Flutter source code I guess... I tried pub get and pub upgrade, uninstalling the plugins and installing them again, deleting the Flutter files and extracting them again but nothing worked. Thank you!
/C:/src/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/pull_to_refresh-1.6.4/lib/src/smart_refresher.dart:434:9: Error: No named parameter with the name 'keyboardDismissBehavior'.
keyboardDismissBehavior:
^^^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/flutter/packages/flutter/lib/src/widgets/scroll_view.dart:588:9: Context: Found this candidate, but the arguments don't match.
const CustomScrollView({
^^^^^^^^^^^^^^^^
FAILURE: Build failed with an exception.
* Where:
Script 'C:\src\flutter\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 904
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\src\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 33s
Exception: Gradle task assembleDebug failed with exit code 1
I think the problem may be in your version of Flutter. Please try and run flutter doctor -v.
If it works, then add the result in the question and we will be able to find the error.
If it doesn't work, then try reinstalling your flutter.
You can run :
flutter clean
flutter pub get

Task 'continue' not found in root project 'Demo2'

I built an android project, and when I ran it, there was the following problem. even if I created a new project in any directory, the problem also appeared. so what's going on here?
BUILD FAILED in 0s
Executing tasks: [:app:assembleDebug]
FAILURE: Build failed with an exception.
What went wrong:
Task '–continue' not found in root project 'Demo2'.
Try:
Run gradle tasks to get a list of available tasks. Run with --stacktrace > option to get the stack trace. Run with --info or --debug option to get >
more log output.
Get more help at https://help.gradle.org
BUILD FAILED in 0s
This looks strange. The error seems to be the – character, which is not a double-dash -- but rather what happens sometimes when a text editor transforms a double in a long one.
--continue is not a task but a Gradle command line flag used to tell a build to continue executing even after a task fails.
Without more context regarding the creation and exact steps to launch the build, it is impossible to say more as to why this happens in your case.

Categories

Resources