Target file "build_runner" not found. - Flutter GraphQL - flutter

flutter run build_runner build - return the following result
Target file "build_runner" not found.
This is supposed to generate model classes from schema, but stuck in the above listed issues.

The issue is with the package dependencies. Executing this flutter pub upgrade --major-versions will solve this issue.

Related

FirebaseAppPlatform.verifyExtends error while running flutter test

When I run my bitbucket pipeline for my project im getting an error during flutter test:
/root/.pub-cache/hosted/pub.dartlang.org/firebase_core-1.24.0/lib/src/firebase_app.dart:18:25: Error: Member not found: 'FirebaseAppPlatform.verifyExtends'.
FirebaseAppPlatform.verifyExtends(_delegate);
^^^^^^^^^^^^^
When I run flutter test in my terminal I don't have these issues.
My pipeline script is:
Build Setup
flutter clean
flutter pub get
flutter pub run build_runner build
bash <(curl -s https://raw.githubusercontent.com/objectbox/objectbox-dart/main/install.sh)
flutter test
Because there are some breaking change of firebase_core_platform_interface that do not comply with semantic versioning:
https://github.com/firebase/flutterfire/issues/9806
You need to overwrite this library:
Root cause
You are update or installing only a subset of the Firebase plugins (firebase_core, firebase_analytics,...)
Solution
Solution 1: (preferred) Updating to the latest version with flutterfire update check the docs here. But it is not easily because your project will have a lot of packages dependencies to each other like flutter version 2 or 3, so on. Anyway, it is long term solution.
Solution 2: (Fix to run)
You can add to your pubspec.yaml
dependency_overrides:
firebase_core_platform_interface: 4.5.1
Solution 3: (Fix to run)
Update dependencies with this below command line:
flutter pub upgrade --major-versions
Finally, Run the project again by following stuffs:
flutter clean
flutter pub get
cd ios && rm -f Podfile.lock
cd ios && pod install --repo-update
flutter run
That's it!
Run "flutter pub upgrade --major-versions"
run this
flutter pub upgrade --major-versions
than run this
flutter upgrade
I changed my flutter version via flutter channel master. This changed automatically my pubspec.lock.
In my case, restoring previous version of pubspec.lock solved the problem (pug get needed).

Differences dart pub get and flutter pub get

I have been using flutter pub get for updating pubspect.yaml
Now I have found that there is a similar command dart pub get
What are the differences between these two commands?
Using the command flutter pub get you are getting dart packages for Flutter.
Using dart pub get you are getting Dart packages.
You can create dart projects without Flutter and there you’ll need use the command dart pub get.
Every Flutter project is a Dart project
but not every Dart project is a Flutter project, because Flutter is a UI kit or framework for building UIs in the Dart programming language.
When dart pub get gets new dependencies, it writes a lockfile to ensure that future gets will use the same versions of those dependencies. Application packages should check in the lockfile to source control; this ensures the application will use the exact same versions of all dependencies for all developers and when deployed to production. Library packages should not check in the lockfile, though, since they’re expected to work with a range of dependency versions.
If a lockfile already exists, dart pub get uses the versions of dependencies locked in it if possible. If a dependency isn’t locked, pub gets the latest version of that dependency that satisfies all the version constraints. This is the primary difference between dart pub get and dart pub upgrade, which always tries to get the latest versions of all dependencies.
When running flutter pub get (Packages get in IntelliJ or Android Studio) for the first time after adding a package, Flutter saves the concrete package version found in the pubspec.lock lockfile. This ensures that you get the same version again if you, or another developer on your team, run flutter pub get.

Flutter - Overridden dependencies

After running "flutter pub get", I got this error:
Warning: You are using these overridden dependencies:
! path 1.6.4
That's not an issue. That happens because you (or any other transitive dependency) may be overriding some dependency that you are already using. For example, if you are using path: 0.X.X and some other dependency use dependency_overrides to make sure that is using path: 1.6.4, it will present you that message.
Overall, you shouldn't have to worry with that and sometimes it is actually required in order to some dependencies work all together.
Please give more details so that i can answer it better. Attach your pubspec.yaml.
But now i can tell you some methods which should work..
first of all see if you are using the latest version of all dependencies or not then:
try:
restarting your ide
flutter clean
if these two don't work then at last try
flutter pub cache repair
I encountered the same error after cloning a flutter repository. I initially mistook the error for being a build issue when it's just a warning that won't stop your app from running.
I solved the build issue I was having with the freshly cloned project by running this command inside the app's root directory: flutter pub run build_runner build

flutter auto route generator error : [dynamic] is not a class

when I am trying to generate the routes for my app using flutter pub run build_runner build
I'm getting an error and the generated class can't be generated
I only see [dynamic] is not a class in the generated class
try to clean and rebuild it ,It worked for me.
flutter packages pub run build_runner clean
then
flutter packages pub run build_runner build
According to the documentation:
Make sure you always Save your files before running the generator, if that doesn't work you can always try to clean and rebuild.
Then:
flutter packages pub run build_runner clean

Duplicate R.class after renaming package name for my Android Studio Flutter app

Tried renaming my Android Studio flutter app package, and it is tunring out as a mess. How can I solve this issue?
Build is failing with the error message:
Execution failed for task ':app:multiDexListDebug'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Error while merging dex archives:
Type com.xxxxx.R is defined multiple times:
....\AndroidStudioProjects\xxxx\build\app\intermediates\compile_and_runtime_not_namespaced_r_class_jar\debug\R.jar: D8: Type com.xxxx.R is defined multiple times: ....\AndroidStudioProjects\xxxx\build\app\intermediates\compile_and_runtime_not_namespaced_r_class_jar\debug\R.jar:com/xxxx/R.class, ....\AndroidStudioProjects\xxxx\build\app\intermediates\javac\debug\classes\com\xxxx\R.class
Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.
Try to run flutter clean in the terminal first. Or remove /build directory by yourself manually.
On terminal type flutter clean
Restart VSCode
Run flutter get package
this happens because the library you are using uses the same dependences.
SOLUTION 1
in VSCode Search (Ctrl+Shift + P)
in your error com.xxxxx.R. search for keywords from that error.
If there are the same dependences, it means that there are duplicate dependences.
Solution: Delete one of the package you are using.
SOLUTION 2 (Recommended)
in VSCode Search (Ctrl+Shift + P)
in your error com.xxxxx.R. search for keywords from that error.
Find a library that uses the same dependences, then update to the latest package version
4.This solution will keep the library you are using without deleting it
Try flutter clean && flutter get package
And try to use a package https://pub.dev/packages/change_app_package_name
Steps:
dev_dependencies:
change_app_package_name: ^1.0.0
Update dependencies
flutter pub get
Run this command to change the package name.
flutter pub run change_app_package_name:main com.new.package.name
(like flutter pub run change_app_package_name:main com.example.app)