Flutter Execution failed for task ':app:processDebugManifest' - flutter

I am new with Flutter, at first my projects were running good but suddenly I started getting this problem:
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
Unable to make field private final java.lang.String java.io.File.path accessible: module java.base does not "opens java.io" to unnamed module #1f05eb0a
Now whenever I run project or even I tried to make new project I get error like this, I have even tried the available answers related to this query but failed to debug it..
here's my flutter version:
PS C:\Work\t_post> flutter doctor -v
[√] Flutter (Channel stable, 2.2.2, on Microsoft Windows [Version 10.0.19042.1052], locale en-US)
• Flutter version 2.2.2 at C:\Work\flutter
• Framework revision d79295af24 (2 weeks ago), 2021-06-11 08:56:01 -0700
• Engine revision 91c9fc8fe0
• Dart version 2.13.3
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at C:\Users\User\AppData\Local\Android\sdk
• Platform android-30, build-tools 30.0.3
• Java binary at: C:\Program Files\Java\jdk-16.0.1\bin\java
• Java version Java(TM) SE Runtime Environment (build 16.0.1+9-24)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[!] Android Studio (not installed)
• Android Studio not found; download from https://developer.android.com/studio/index.html
(or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).
[√] VS Code (version 1.57.1)
• VS Code at C:\Users\User\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.23.0
[√] Connected device (3 available)
• sdk gphone x86 arm (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 91.0.4472.124
• Edge (web) • edge • web-javascript • Microsoft Edge 91.0.864.54
! Doctor found issues in 1 category.
And here's my pubspec.yaml file:
name: t_post
description: A new Flutter project.
# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
sdk: ">=2.12.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
dev_dependencies:
flutter_test:
sdk: flutter
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true

Just downgrading the JDK version from 16 to 15 worked for me.

Related

build runner package in my flutter app for JSON serialization not working

I'm using build_runner package in my flutter app for JSON serialization. I've correctly installed it in pubspec.yaml file under dev dependencies. but when I try to use flutter pub run build_runner build it releases the following.
C:\Users\MoBix\Music\islamic_social_media>flutter pub run build_runner build
Unhandled exception:
Bad state: Unable to generate package graph, no `C:\Users\MoBix\Music\islamic_social_media\.dart_tool\flutter_gen\pubspec.yaml` found.
#0 _pubspecForPath (package:build_runner_core/src/package_graph/package_graph.dart:232:5)
#1 _parsePackageDependencies (package:build_runner_core/src/package_graph/package_graph.dart:206:21)
#2 PackageGraph.forPath (package:build_runner_core/src/package_graph/package_graph.dart:101:33)
<asynchronous suspension>
#3 main (file:///C:/flutter/.pub-cache/hosted/pub.dartlang.org/build_runner-2.1.5/bin/build_runner.dart:27:30)
<asynchronous suspension>
pub finished with exit code 255
my pubspec.yaml
dev_dependencies:
flutter_launcher_icons: ^0.9.2
flutter_app_name: ^0.1.1
build_runner:
flutter_test:
sdk: flutter
my flutter doctor -v
C:\Users\MoBix>flutter doctor -v
[√] Flutter (Channel stable, 2.5.3, on Microsoft Windows [Version 10.0.19043.1348], locale en-US)
• Flutter version 2.5.3 at C:\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 18116933e7 (6 weeks ago), 2021-10-15 10:46:35 -0700
• Engine revision d3ea636dc5
• Dart version 2.14.4
[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at C:\Users\MoBix\AppData\Local\Android\sdk
• Platform android-Sv2, build-tools 31.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Android Studio (version 2020.3)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
[√] Connected device (2 available)
• Chrome (web) • chrome • web-javascript • Google Chrome 96.0.4664.45
• Edge (web) • edge • web-javascript • Microsoft Edge 94.0.992.50
• No issues found!
What is the fix for this?
It's interesting that it points to .dart_tool/flutter_gen/pubspec.yaml. This issue mentions this problem when generate: true is set in the pubspec.yaml.
If you don't need that, try removing it. Also, a flutter clean and flutter pub get might be necessary.
In my case this was happening to me trying to generate the code for testing using mockito and the annotation:
#GenerateMocks([ClassToMock])
The errorappear trying to do flutter pub run build_runner build and the <...>/.dart_tool/flutter_gen/ path doesn't exist.
The solution was creating an empty .dart_tool/flutter_gen/pubspec.yaml file:
mkdir .dart_tool/flutter_gen && touch .dart_tool/flutter_gen/pubspec.yaml
And fullify it with (as pointed here):
name: test
description: A new Flutter application.
version: 1.0.0
dependencies:
dev_dependencies:

Why does every code related to font_awesome_flutter package gives an error including the import package code?

SITUATION
I made a project in another device and when I am using the same project in another device. It gives an font_awesome_flutter package error all over the code. And gives an error saying, Target of URI doesn't exist: 'package:font_awesome_flutter/font_awesome_flutter.dart'.
Try creating the file referenced by the URI, or Try using a URI for a file that does exist. Same issue occurs in vs code as well as in android studio
How should I tackle this?
TRIED
I also tried running flutter pub get but does not work.
pubspec.yaml file
dependencies:
flutter:
sdk: flutter
font_awesome_flutter: ^8.8.1
cupertino_icons: ^0.1.3
flutter doctor -v seems good too.
PS G:\Current Work\nikeshoeapp-20200809T055655Z-001\nikeshoeapp> flutter doctor -v
[√] Flutter (Channel stable, 1.20.1, on Microsoft Windows [Version 10.0.19041.388], locale en-US)
• Flutter version 1.20.1 at C:\src\flutter\flutter
• Framework revision 2ae34518b8 (3 days ago), 2020-08-05 19:53:19 -0700
• Engine revision c8e3b94853
• Dart version 2.9.0
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
• Android SDK at C:\Users\Aman Chaudhary\AppData\Local
• Platform android-30, build-tools 30.0.1
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.
[√] Android Studio (version 4.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 48.0.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[√] VS Code (version 1.47.3)
• VS Code at C:\Users\Aman Chaudhary\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.13.2
[√] Connected device (1 available)
• sdk gphone x86 arm (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator)
• No issues found!
Please Let me know what should I try?
Try file -> invalidate/restart and then click on invalidate and restart.
If it doesn't work, try running this
’’’
flutter clean pub cache
’’’
I also faced this problem, in my case i finished my project and done a
flutter clean and done flutter build apk --release
and the error was
Target of URI doesn't exist: 'package:font_awesome_flutter/font_awesome_flutter.dart'. Try creating the file referenced by the URI, or Try using a URI for a file that does exist.
Solution
These commands saved me
flutter clean
flutter packages get
flutter pub get
flutter build apk --release
Still i didn't get the difference between flutter packages get and flutter pub get

Flutter auto_route_generator not building, FormatException: Not an instance of List

I'm trying to run Flutter pub run build_runner build,
to generate a router.g.dart file for navigation.
I've run a build_runner clean, a whole project clean then build but no luck.
Im following a tutorial, he just seems to run it exactly with the code I have and its fine. No one else in the comments seem to have this issue and I can't find anything about it online.
It fails saying:
[SEVERE] auto_route_generator:autoRouteGenerator on lib/app/router.dart:
FormatException: Not an instance of List.
[INFO] Running build completed, took 16.2s
[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 48ms
[SEVERE] Failed after 16.3s
pub finished with exit code 1
My router.dart code:
import 'package:auto_route/auto_route_annotations.dart';
import 'package:stacktest/ui/views/covers/cover_view.dart';
import 'package:stacktest/ui/views/home/home_view.dart';
import 'package:stacktest/ui/views/startup/startup_view.dart';
#MaterialAutoRouter()
class $Router {
#initial
StartupView startupViewRoute;
HomeView homeViewRoute;
CoverView coverViewRoute;
}
Pubspec.yaml:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.3
stacked: ^1.7.1+1
auto_route: 0.6.1
stacked_services: 0.4.4+3
dev_dependencies:
build_runner: 1.10.0
auto_route_generator: 0.6.0
flutter_test:
sdk: flutter
Flutter doctor -v
✓] Flutter (Channel master, 1.20.0-8.0.pre.41, on Mac OS X 10.15.5 19F101, locale en-AU)
• Flutter version 1.20.0-8.0.pre.41 at /Users/mikaelwills/Documents/Flutter
• Framework revision fd80503fd3 (34 hours ago), 2020-07-10 14:41:02 +0530
• Engine revision 9b3e3410f0
• Dart version 2.9.0 (build 2.9.0-20.0.dev 06cb010247)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/mikaelwills/Library/Android/sdk
• Platform android-29, build-tools 29.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.5, Build version 11E608c
• CocoaPods version 1.8.4
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 3.5)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 42.1.1
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
[✓] VS Code (version 1.47.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.12.2
[✓] Connected device (2 available)
• Web Server (web) • web-server • web-javascript • Flutter Tools
• Chrome (web) • chrome • web-javascript • Google Chrome 83.0.4103.116
• No issues found!
Since the version 0.6.0 there were some breaking changes in the auto_route package, the most important was that It was changed the way routes are declared from class fields to a static list. You can check more details about it here.
So, in order to fix it just update it using a static list as follows:
#MaterialAutoRouter(
routes: <AutoRoute>[
MaterialRoute(page: StartupView, initial: true),
MaterialRoute(page: HomeView),
MaterialRoute(page: CoverView),
],
)
class $Router {}
and then run the build runner command: flutter pub run build_runner watch --delete-conflicting-outputs
Another option could be use an earlier version like the 0.5.0, but it's recommended to keep updated, for more info please check the documentation in theauto route package.

I have an error in vscode when trying to install flame under pubspec.yaml

I'm trying to install flame but whenever I run the pub get it gives me a really long error "Because every version of flutter_test from sdk depends on xml 3.6.1 and tiled >=0.4.0 depends on xml ^4.2.0, flutter_test from sdk is incompatible with tiled >=0.4.0." And then under it is a version solving failed error message.
[√] Flutter (Channel stable, v1.17.5, on Microsoft Windows [Version 10.0.18363.900], locale en-US)
• Flutter version 1.17.5 at C:\Users\marci\Downloads\flutter
• Framework revision 8af6b2f038 (7 days ago), 2020-06-30 12:53:55 -0700
• Engine revision ee76268252
• Dart version 2.8.4
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.0)
• Android SDK at C:\Users\marci\AppData\Local\Android\sdk
• Platform android-30, build-tools 30.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.
[√] Android Studio (version 4.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 47.1.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[√] VS Code (version 1.46.1)
• VS Code at C:\Users\marci\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.12.1
[!] Connected device
! No devices available
! Doctor found issues in 1 category.
name: ggg
description: A new Flutter project.
publish_to: 'none'
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.3
flame: ^0.24.0
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
I had the same problem today and checked on the Flame Discord channel.
They told me they have a conflict with their lib with stable flutter channel.
Recommendation is to change to Flutter Channel Beta.
I did that, then did Flutter Upgrade, then finally Flutter Pub Get and it worked.
Terminal Commands
To check which channel you are currently on
Flutter Channel
To change to the beta channel
Flutter Channel Beta
To get the beta version
Flutter Upgrade
So, when I have the same problem with you when I tried it.
Here's my solution:
In your dependencies: section inside the pubspec.yaml file, change the flame section without any version tag:
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.3
flame:

flutter: ">=0.2.4 <2.0.0" pub get failed (65) when cloud_firestore package is used in pubspec.yaml

When I tried to add the google_sign_in,flutter_auth and cloud_firestore it is throwing me the error that flutter: ">=0.2.4 <2.0.0".I tried to run flutter dector -v the output is
[✓] Flutter (Channel stable, v1.5.4-hotfix.2, on Linux, locale en_US.UTF-8)
• Flutter version 1.5.4-hotfix.2 at /home/ramu/Downloads/tools/flutter
• Framework revision 7a4c33425d (4 weeks ago), 2019-04-29 11:05:24 -0700
• Engine revision 52c7a1e849
• Dart version 2.3.0 (build 2.3.0-dev.0.5 a1668566e5)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /home/ramu/Android/Sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• ANDROID_HOME = /home/ramu/Android/Sdk
• Java binary at: /snap/android-studio/73/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
• All Android licenses accepted.
[✓] Android Studio (version 3.3)
• Android Studio at /snap/android-studio/73/android-studio
• Flutter plugin version 34.0.1
• Dart plugin version 182.5215
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1248-b01)
[✓] VS Code (version 1.34.0)
• VS Code at /usr/share/code
• Flutter extension version 3.0.2
[!] Connected device
! No devices available
! Doctor found issues in 1 category.
firebase_auth: ^0.6.2+1
google_sign_in: ^3.2.2
cloud_firestore: ^0.8.2+3
Try updating your environment sdk in pubspec.yaml from >=0.2.4 <2.0.0 to >=2.1.0 <3.0.0
The upper bound for your environment sdk is below version 2.0.0 but google_sign_in ,firebase_auth, and cloud_firestore requires at least >=2.0.0-dev.28.0 (which is newer then what you have specified for your project).
Try to delete that project folder and create a new one and paste all the code in the newly created project.