Flutter, Android Manifest issue with flutter run -t method - android

I need to set 2 main files for test and dev environment. When I try to run
flutter run -t test_app/lib/main.dart
I get following errors:
AndroidManifest.xml could not be found.
Please check ***/android/app/src/main/AndroidManifest.xml for errors.
No application found for TargetPlatform.android_x86.
Is your project missing an android/app/src/main/AndroidManifest.xml?
Consider running "flutter create ." to create one.
And when I use:
flutter build apk -t test_app/lib/main.dart
I get:
[!] Your app is using an unsupported Gradle project. To fix this problem, create a new project by running `flutter create -t app <app-directory>` and then move the dart code, assets and pubspec.yaml to the new
project.
I add the configuration to run this 2 different main files and it works but I need to run this from command line and that's the problem.
I saw similar issues and I tried
run flutter clean and flutter pub get
What can cause this issue? Any ideas how to resolve this?

You can check this reference
Try to fix it by deleting the app.apk in the build/app/outputs/apk.

Try deleting this Flutter project and create a new Flutter project.

Related

flutter build ios command is always stucked at └─Compiling, linking and signing... ⣯

Running pod install... 2,087ms
Running Xcode build...
└─Compiling, linking and signing... ⣻
flutter build ios command is always stuck at └─Compiling, linking, and signing... ⣯
make a backup of the project and try this
delete iOS folder
flutter create (new project with same name)
copy iOS folder to the replace deleted file
flutter clean
flutter run
new create a flutter
copy lib and assent file
add dependencies
flutter ios build
I have ran into the same issue after running flutter build ipa. I honestly do not know what caused the problem.
However, killing the process, restarting my computer, and running the process again seemed to have fixed the issue for me.

How to fix "Finished with error: Gradle task assembleDebug failed with exit code -1" error when i run flutter project

"Finished with error: Gradle task assembleDebug failed with exit code -1"
I make a new basic flutter project, and I got this error when I run flutter doctor everything is well, no issues detected. I have tried flutter clean, and try to rebuild and the messages are the same.
anyone can help me please to fix this problem.
error:
Flutter doctor:
logcat:
device connected:
Module Window:
Open your android folder with the android studio it'll help you to find out whats the issue. also, check this answer too.
Flutter provides a command to update the Android SDK path:
Use flutter config --android-sdk <path-to-your-android-sdk-path>
I got same error code a few days ago when I try to run all my Flutter projects. To make sure you encounter the same problem as I did;
First, go to your project directory -> open android folder -> check if there's a gradlew.bat file inside. <project_name>\android\gradlew.bat. If there's no such file, then you can follow along.
Here's what I did:
Run flutter create -t <project_name>, by using this command, it will ensure that there will be gradlew.bat file inside the project.
Go to that project directory <project_name>\android, copy that gradlew.bat file.
Paste it to the same directory path (<project_name>\android) of one of your current not-working Flutter project.
Try to run the flutter run command on that project.

Issue in building apk in flutter application

i have completed all the steps like creating keyStore , changing in build.gradle etc.
but i am facing a issue while running this command
flutter build apk --release
whenever i run this command terminal shows that
I am using Linux
flutter: command not found
Have you added installdirectory/flutter/bin to your path variables?
Can you Give us a little more context, like , are you on Windows or mac or Linux?
you should locate flutter in path click here

Can't load Kernel binary: Invalid kernel binary format version. No active package webdev

After running webdev serve it gives "Can't load Kernel binary: Invalid kernel binary format version.
No active package webdev."
this error
tried this and it added some dependencies
flutter packages pub global activate webdev
Delete the bin/cache directory in your Flutter installation directory, then run flutter doctor.
Open Flutter SDK folder, go to bin/cache and delete all the files + folders then run flutter doctor, and then flutter upgrade.
instead of webdev serve try to use flutter packages pub global run webdev serve and for getting and upgrading packages you can use flutter packages get and flutter packages upgrade respectively.
I would add that deleting the bin/caches folder seems to be the solution when your xcode build freezes on the launch screen. It seems to be related to upgrading Flutter and/or rolling back afterwards (my case).
I had the same error in Xcode.
pod update solves the problem.
I run flutter clean within the same terminal of my flutter project and that seems to work out
For me,
downgrading from 3.0.0 to 2.10.5 required pretty much all the solutions in this thread, and it worked.
Steps I followed,
rm -rf <path to flutter repo>/bin/cache
flutter doctor -v
flutter clean
flutter pub get
flutter pub cache repair
cd in ios directory in the project and pod install
Steps 5 & 6 were probably wasn't necessary but I did it anyway. Step 6 is executed at flutter run anyway.
Run the following commands in the terminal inside the project directory
flutter clean
flutter pub get
For me it was necessary to delete "flutter/bin/cache/flutter_tools.stamp".
https://github.com/flutter/flutter/issues/67222

Visual Studio Code - Target of URI doesn't exist 'package:flutter/material.dart'

I've just set up my Macbook for flutter development,
So I downloaded flutter SDK, and placed it in my Documents. After, I set up my path variable to work with flutter in my command line.
I execute the command flutter create todolist so I achieve a blank project.
I also set up my visual studio code with Dart-Code so I have the proper syntax highlight, IntelliSense, etc.
So when I open visual studio code, it highlights the import method, like the following image:
This means that it also highlights the classes that are correct, making it completely hard to understand if it's a real error or not.
I have executed both pub get and flutter packages get and got everything correctly.
I have my path variables all correctly.
Why is it highlighting it cannot find that 'import' package?
flutter packages get
Restart Visual Studio Code
source: https://flutter.dev/docs/development/packages-and-plugins/using-packages
flutter clean
flutter packages get
flutter packages upgrade ( Optional - use if you want to upgrade packages )
Restart Android Studio or Visual Studio
Author of the Dart Code plugin here! From the screenshot, I would say this is because your flutter project is in a sub-folder of the folder open in Code. We only scan the opened-folder to check whether it's a Flutter project - which then changes the SDK we launch and also enables the Flutter functionality (like the daemon and debugger).
You should re-open the "todo" folder directly.
If you want to have multiple projects open together, use multi-root workspaces, since Dart Code is multi-root-aware and will check each of the folders in the workspace when deciding if it needs to enable Flutter functionality.
Update
This case should be better supported in the Dart plugin now, so opening the immediate parent folder of a Flutter project should work as expected.
If you have used the flutter packages get command and the error still persists, you can simply reload VS code the Developer: Reload Window command. Simply type that in after pressing Ctrl+Shift+P (Cmd+Shift+P for Mac users). It will clear the error. It's like refreshing VS Code.
Restarting visual studio code worked for me !
Restart the VS Code you will see magic!
If that's not work then check the indent of your dependencies in the pubspec.yaml
Open the project after deleting .idea folder and .dart_tool
This worked for me in Android Studio as well as VS Code. I only had to run these lines in my terminal/command prompt and problem was solved. There was no need to restart any of the IDEs again
flutter packages get
Optionally you also run.
flutter upgrade
-Edit:- Now this happens most of the time to me, whenever I open some old project(flutter project), it is basically because of not downloading or not having the packages to refer, for the vscode, In simple just blindly do A PUB GET or just hit CTRL/COMMAND + s in pubspec.yaml file, and you are good to go(sometimes it might take some time to get everything set(depends on your system specs.))!
-old answer starts here!
Simple thing I did after Someone said here to restart the VSCode and I did that, and now everything works fine.
For me it was because just when I was creating project I got an notification for updating my dart(or related) extension and for that I did it and boom as my project started, it just gave me around 30 errors which do scared but the simple FIX was to RESTART THE EDITOR.
Open the command palette (ctrl+shift+p), type flutter: get packages (should autocomplete); after it resolves open the command palette again and type reload window and execute the command. This should resolve the issue as quickly as possible.
Close the VS Code and Run it again
The quickest way to get Dart-Code to reliably find your Flutter install and use it is to create a new FLUTTER_ROOT environment variable and set it to your Flutter path.
Basically
Check for correct indentation of your package in dependencies
if your editor supports, it automatically runs -> flutter pub get
Either way -> open terminal-> flutter pub get or flutter packages get
check .packages file, see if your package is present else reinstall package
Most important : Restart your IDE (Visual studio or Android Studio)
Start debugging your project
Most probably , your errors will be fixed by then
Hope it works for you
try to run flutter clean
then restart VS Code. This did it for me.
I also had this issue. I had both VS code and Android studio installed in my system.
The error was in VS code.
When i opened the same project on Android studio, the dependency was not actually added to pubsec.yaml. I added it there and ran pub.get.
When I returned to VS Code and everything was working fine.
So, Try opening it in other editor if you have, or through NotePad.
Edit:
Opening widget_test.dart and running it should also solve your issue.
Also happened to me while trying to run the project inside of another directory.
Worked by using the root directory of the main project
Just add
dependencies:
http: ^0.12.0
in pubspec.yaml file
please check http documentation
If you execute From the terminal: "Run flutter packages get" and the error continues, check is all packages directories are listed at '.packages' file. - Sometime you have the packages, but it is not configured at this file.
Execute one of the following:
flutter upgrade
flutter pub get
flutter packages get
Warning! This package referenced a Flutter repository via the
.packages file that is no longer available. The repository from which
the 'flutter' tool is currently executing will be used instead.
running Flutter tool: /opt/flutter previous reference :
/Users/Shared/Library/flutter This can happen if you deleted or moved
your copy of the Flutter repository, or if it was on a volume that is
no longer mounted or has been mounted at a different location. Please
check your system path to verify that you are running the expected
version (run 'flutter --version' to see which flutter is on your
path).
Checking the output of the flutter packages get reveals that the reason in my case was due to moving the flutter sdk.
Do not forget:
export PATH="$PATH:/home/[xxxxx]/flutter/bin
For me, it works:
flutter upgrade
flutter packages get
You can check with
flutter doctor
flutter --version
Go to pubsec.yaml file and add this directly after cupertino_icons:
webview_flutter:
Then press Packages get on the top right corner and it will work fine with you.
Add dependencies.
for example:- import 'package:audioplayers/audio_cache.dart';
in the above package if we only use this package then it shows error
but if we add dependencies in pubspec.yaml
such as
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
audioplayers: ^0.14.1
then click on packages get.
as you see this, I can also insert dependencies so if you insert dependencies along with your package then you are good to go.
If you change the property name in pubspect.yaml all your package in lib folder turn to red with the error Target of URI doesn't exist...
I was using (goggle location picker (with much more customisation in functions and UI) ) so I copy this package(complete) and using in my app in one folder but since dart code analyser analyses one flutter project so I found that those which are referencing from inside of this package is not working then I copy only lib folder(of google location picker) in my original project folder and voila this worked for me.
This solution took me a time of 3 days.
I know this is not the question but it might help someone to save 3 days.
I had this problem in Android Studio with the rflutter_alert package. After inserting the dependencies, I imported the package in my project with ctrl+space key and I have added import 'package:rflutter_alert/'; the problem is that this was not correct. The correct form was package:rflutter_alert/rflutter_alert.dart
right vs wrong comparison
i faced the same issue with the bloc package, after i restarted visual studio i installed the package again using flutter pub add bloc and it installed properly this time. Note that i tried installing it several times, this time it was a charm
Restart you android studio or visual studio.
Run commands
i - flutter clean.
ii - flutter pub get.
iii - flutter upgrade.
if these work not work try this:
Check your dart SDK path.
Don't forget to save pubspec.yaml before running "flutter pub get". Restarting Visual Studio Code is not enough. That was my solution. Sometimes when you work with intellij you forget that ...
When you usually get this error message:
Target of URI doesn't exist: 'package:foo'. Try creating the file
referenced by the URI, or Try using a URI for a file that does exist.
Example:
Target of URI doesn't exist:
'package:random_string/random_string.dart'. Try creating the file
referenced by the URI, or Try using a URI for a file that does exist.
import 'package:random_string/random_string.dart';
It is because a dependency is missing.
So all you have to do is find out what packages are needed by googling your package name.
Install the dependency:
$ flutter pub get
and add the dependency in the pubspec.yaml file:

Categories

Resources