Flutter released app not working on the device, when installed - dart

When I am debugging the app, everything works fine, but after I perform these commands:
flutter clean
flutter build apk
flutter install
The installed app is not working properly (Not loading data from API). Any ideas?
pubspec.yaml:
name: test_app
description: A new Flutter project.
https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
http: ^0.12.0+2
cupertino_icons: ^0.1.2
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true

Since this is a problem that might concern other developers and the question deserves an answer I've decided to post it as an answer rather than a comment.
When you create a new flutter project, the framework won't add any permissions to AndroidManifest.xml or any configurations to Info.plist for iOS. This has to be done manually by the developer.
Also, there are some flutter packages that take care of runtime permissions, but these permissions require user input (grant permission or deny it). Runtime permissions are sensitive permissions but internet access permission is not in this category, so there's no need for requesting user feedback on it.
To be even more confusing, the flutter framework can do API requests in debug mode or on simulators without Internet permission added to the AndroidManifest.xml (maybe in the future we'll get an error/warning) about missing permission from the flutter team, until then, don't forget to add it in your AndroidManifest.xml file.

Below steps work for me
Check your flutter channel in terminal
run flutter channel
If your channel is in Dev
Flutter channels:
master
* dev
beta
stable
Change your channel to stable
run flutter channel stable
It will ask for flutter upgrade.
run flutter upgrade
you final output will be
Flutter channels:
master
dev
beta
* stable
Voila!!!

Related

Flutter iOS App on an iOS Simulator running on an M1 Mac

Is there an issue with Flutter iOS apps on an iOS simulator (iPhone 12 Pro Max) running on an M1 Mac with Big Sur 11.2.2 and Flutter 1.22.6 ?
You see, my Flutter iOS app (using multiple Flutter plugins) was developed on an Intel-based Mac running Catalina (10.15.7) and Flutter 1.22.5 and it works, but when I moved to an M1 based Mac running Big Sur and Flutter 1.22.6, I’m having the Cocoapod’s error:
[!] Automatically assigning platform `iOS` with version `9.0` on target `Runner` because no platform was specified. Please specify a platform for this target in your Podfile.
Note that on this M1 mac, 'flutter doctor' is successful and I can create the Flutter test app and run it on an iOS simulator so I think its setup properly.
I have also tried the solutions suggested with past posts having this symptom to no avail. I have tried the following:
1- I uncommented the line 'platform :ios, '9.0'' in my pods file.
2- I ran the following CLI commands in the terminal:
flutter clean
rm -Rf ios/Pods
rm -Rf ios/.symlinks
rm -Rf ios/Flutter/Flutter.framework
rm -Rf ios/Flutter/Flutter.podspec
cd ios
pod install
cd ..
flutter build ios
The result of trying both suggestions above is the same 'Error running pod install' error with no other error messages mentioned.
The only thing I can think of at this point is that there is a problem with the Flutter plugins I am using when running in an iOS simulator on an M1. Again, these plugins work on an Intel-based Mac running Catalina. If so, unfortunately, the error doesn’t tell me which one. The plugins that I use are:
dependencies:
flutter:
sdk: flutter
provider: ^4.1.3
sqflite: ^1.3.2+1
googleapis: ^0.56.1
googleapis_auth: ^0.2.12
http: ^0.12.2
url_launcher: ^5.7.2
flutter_secure_storage: ^3.3.5
tuple: ^1.0.3
image_picker: ^0.6.7+12
intl: ^0.16.1
fraction: ^1.2.1
archive: ^2.0.13
path_provider: ^1.6.24
path: ^1.7.0
image_cropper: ^1.3.1
flutter_image_compress: ^0.7.0
All help / suggestions greatly appreciated.
It's not yet supported (Coming in this PR)
Flutter has disabled running on simulators running on ARM architecture. They've done this because a flutter dependency (iOS engine Flutter.framework) didn't have arm64 slices. There is an open pull request to add support for iOS simulator on M1 macs (arm64): https://github.com/flutter/flutter/pull/85059
I initially tried to get this working for myself, but the issue is Generated.xcconfig contains code which disables arm64 architecture for the simulator, and this file is generated by Flutter internally. Once you manually change this, it still fails. If you tried to build with Xcode, you might get this error message during the linking process:
Undefined symbol: _OBJC_CLASS_$_ClassName
and lots more. I'd recommend building with Xcode if you don't see enough logs or information to debug the build process.
Automatically assigning platform is not an error
Automatically assigning platform iOS is not actually an error, it's just telling you its defaulted to iOS platform. It then failed, so in this case, you should've provided more error information.
I also faced this issue.
Update iOS version to 10.0 in the podfile.
It worked for me.

Dart SDK not install

I want to get started with flutter web so I am trying to install dart-sdk for windows (stable version Link: https://gekorm.com/dart-windows/) but it doesn't download.it always show a message,download failed:The operation timed out.
actually you don't need to install dart SDK separately, because flutter SDK comes with dart SDK together in one zip.
to start flutter web app you need to change flutter channel to beta and enable web configuration :
flutter channel beta
flutter upgrade
flutter config --enable-web
or I recommend downloading the flutter beta SDK from here:
and use separately it from your stable SDK
you can find more info about flutter web here

Version of dart used in my existing project

I have a flutter project. I want to know what version of dart language is used in development of the project. And i also want to know the version of flutter framework which is used for developing the project.
Is there any way to know these details?
I do not have documentation of the project.
I tried flutter doctor command but it gives current version of dart and flutter framework installed in my android studio.
in the pubspec.yaml, you will find the following
environment:
sdk: ">=2.1.0 <3.0.0"
this indicates that this project works with dart 2.1.0 and above
learn more here if you like

update dart sdk for flutter

I would like to use dart SDK >= 2.2.0 with flutter. But my current version used BY Flutter is 2.1.2
flutter --version
Flutter 1.2.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 8661d8aecd (2 months ago) • 2019-02-14 19:19:53 -0800
Engine • revision 3757390fa4
Tools • Dart 2.1.2 (build 2.1.2-dev.0.0 0a7dcf17eb)
I tried to install the 2.2.0 version independently and I succeed :
dart --version
Dart VM version: 2.2.0 (Tue Feb 26 15:04:32 2019 +0100) on "macos_x64"
However, Flutter doesn't use this version as you can see above. I tried to replace files of the dart-sdk used by flutter (flutter/bin/cache/dart-sdk) by the version that I installed independently, but when I try to run Flutter after that I have a snapshot problem so I have put back the original dart-sdk folder in the flutter directory.
Do you have any ideas how can I update it?
PS: I downloaded flutter very recently (10 days ago) from here: https://flutter.dev/docs/get-started/install/macos
It might be due to the fact you are on channel stable which is the most secure builds of the four channels to get updated (channels are listed here)
If you are a bit more curious to try out the new features without having to risk bad builds I advocate channel beta:
Every month, we pick the "best" dev build of the previous month or so, and promote it to beta. These builds have been tested with our codelabs.
where the stable channel has this description:
When we believe we have a particularly good build, we promote it to the stable channel. We intend to do this more or less every quarter, but this may vary. We recommend that you use this channel for all production app releases. We may ship hotfixes to the stable channel for high-priority bugs, although our intent is to do this rarely.
You can change the channel to point at beta by running this command in your terminal:
flutter channel beta followed by flutter upgrade to ensure you have got the last release for this particular branch.
Let me know how this affect your situation.
You have to upgrade flutter from cli with flutter upgrade command. Then flutter will use latest version of Dart SDK. Flutter does not use your local Dart Sdk.
This issue is because of the dart version and by updating flutter the dart version won't update,
the way for solving this is,
first, you need to be on the dev or master channel,
flutter channel master
flutter upgrade
after that run flutter doctor -v as you see your dart is still an old one
in this step, you should update it manually, as the doc says Dart
for Windows user
choco upgrade dart-sdk
for Mac users
if you user brew to install dart
brew upgrade dart
and if you don't, you can install it
brew tap dart-lang/dart
brew install dart
wish this solves your issue.
You might need to Update your pubspec.yaml depending on the flutter channel you want to work on:
If you are on stable channel :
Go into pubspec.yaml and type in:
environment:
sdk: ">=2.2.0 <3.0.0"
(Whatever Dart SDK version you want comes in the front)
dependencies:
cupertino_icons: ^1.0.0
If you are on beta channel :
environment:
sdk: ">=2.12.0 <3.0.0"
dependencies:
cupertino_icons: ^1.0.1
Then if you are on stable channel (or beta), open the terminal in your IDE and enter
flutter channel stable
# or flutter channel beta
flutter upgrade
flutter pub get
Check the version with flutter --version
Hope it helps.
follow some command given below :
1.flutter version -> give all the flutter version list available.
2.flutter version v1.12.13+hotfix.7 -> you can switch to any given flutter version
in your console by 1st command.
Open terminal commands to Upgrade Flutter – Dart SDK
1-> C:\flutter
2->run command " flutter channel master "
3->run command after switching " flutter upgrade "
Now open android studio which automatically fetch updated sdk from flutter folder
You can upgrade dart SDK using terminal by typing flutter upgrade.
This will upgrade both flutter and dart SDK.
Actually flutter upgrade includes the Flutter and Dart SDK and doesn't install them separately.
if you using android studio,
Tools->Flutter->Flutter upgrade
click on flutter upgrade then you can install it
Try this
flutter channel stable
flutter upgrade
or this
flutter channel master
flutter upgrade
it is so simple if dart was installed with flutter just do the below line:
flutter upgrade
If using windows, you can use chocolatey to upgrade sdk by using command.
choco upgrade dart-sdk
If you want the latest pre-release version:
choco upgrade dart-sdk --pre
Yeah, the cause of the problem is inherent in the fact that Flutter does not use the dart present on your Local machine the Flutter sdk instead comes with the
latest compatible dart sdk shipped along with it.
When you run the command flutter version it prints the current flutter version and the current dart-sdk version shipped along with it. If you wish to use a later version of the dart sdk you'll have to upgrade your flutter sdk and if the specific dart-sdk version you want is not yet available for any branch in the stable channel I will suggest you switch to the master or dev channel and hopefully the latest release of those channels will support the required sdk constraint you need. But beware other branches aside the stable branch are not totally safe as you can encounter strange and unresolved errors so have that at the back of your mind.
I'm using flutter upgrade channel stable on macOS and it's working fine
The dark SDK that you updated is probably the one on your global dart installation.
Check your flutter dart path with the command
which flutter dart
If it is looking like this
[/path-to-flutter-sdk]/bin/flutter
/usr/local/bin/dart
you need to change it to use the one associated to flutter:
[/path-to-flutter-sdk]/bin/flutter
[/path-to-flutter-sdk]/bin/dart
To update it, you need to update your $PATH so [/path-to-flutter-sdk]/bin/flutter comes before /usr/local/bin.
I have two version of flutter SDK at the same time for two different flutter projects. I had changed the current SDK to 1.12 so it was complaining about dart SDK version. I changed the current version to 1.20 and the problem solved.
If you struggle to make any of these solutions work, you might have different versions of flutter on your system.
I checked my version on the command line and upgraded via 'flutter upgrade' to the latest stable release, which did not solve the problem in IntelliJ / Android Studio, as that pointed to another local version of flutter.
To check, run 'which flutter' on the command line and check with the version displayed in "Preferences --> Languages & Frameworks --> Flutter" and make sure they point at the same flutter installation.

flutter packages get failed depends on flutter_test any from sdk which requires SDK version <2.0.0, version solving failed

I create a flutter project, and run flutter packeages get,the output as below:
[second] flutter packages get
Waiting for another flutter command to release the startup lock...
Running "flutter packages get" in second...
The current Dart SDK version is 2.0.0-dev.63.0.flutter-4c9689c1d2.
Because second depends on flutter_test any from sdk which requires SDK version <2.0.0, version solving failed.
pub get failed (1)
exit code 1
flutter doctor -v
PS D:\dartstudy\second> flutter doctor -v
[√] Flutter (Channel dev, v0.5.7, on Microsoft Windows [Version 6.1.7601], locale zh-CN)
• Flutter version 0.5.7 at E:\flutter
• Framework revision 66091f9696 (2 weeks ago), 2018-07-09 12:52:41 -0700
• Engine revision 6fe748490d
• Dart version 2.0.0-dev.63.0.flutter-4c9689c1d2
[√] Android toolchain - develop for Android devices (Android SDK 28.0.1)
• Android SDK at f:\Android\Sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.1
• ANDROID_HOME = f:\Android\Sdk
• Java binary at: E:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)
• All Android licenses accepted.
[√] Android Studio (version 3.1)
• Android Studio at E:\Program Files\Android\Android Studio
• Flutter plugin version 26.0.1
• Dart plugin version 173.4700
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)
[√] VS Code, 64-bit edition (version 1.25.1)
• VS Code at C:\Program Files\Microsoft VS Code
• Flutter extension version 2.16.0
[!] Connected devices
! No devices available
! Doctor found issues in 1 category.
the IDE that I use to create a project is VS code.
I changed some versions of flutter sdk, the problems are the same as above,How to fix this problem?
I was having a similar issue:
Running "flutter packages get" in austin-feeds-me-flutter...
The current Dart SDK version is 2.0.0-dev.58.0.flutter-f981f09760.
Because austin_feeds_me depends on palette_generator any which requires SDK version >=2.0.0-dev.61.0 <3.0.0, version solving failed.
pub get failed (1)
Process finished with exit code 1
I fixed it with the following commands:
flutter channel dev
flutter upgrade
Fix source: https://github.com/flutter/flutter/issues/19382
just update your sdk by these codes
flutter channel dev
flutter upgrade
if you live in iran you need to use proxy because google no let you to use its packages
and for scoped_model you need to use below version of it in your pubspec.yaml file
dependencies:
scoped_model: ^1.0.1
and then save the file, your IDE automatically update the package
I solved my error by using any instead of the version codes like this
flutter_test: any
instead of
flutter_test: ^1.1.0+1
Just modify the package version in pubspec.yaml to the latest version fixed my issue.
I know this is an outdated question but I think someone will benefit from this and also the answer is relevant not outdated.
You need to fix environment: in pubspec.yaml to allow the Dart SDK version you are using (the one from Flutter)
environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"
The essential part is <3.0.0
Originally answered here in GitHub by someone called Günter Zöchbauer:- https://github.com/flutter/flutter/issues/21421#issuecomment-418718539
Just upgrade flutter to the latest version. This solved the problem for me.
flutter upgrade //for upgrading flutter enter this in CLI.
I found the solution of this question by myself.I add the system environment variable PUB_ALLOW_PRERELEASE_SDK=false,so Just remove this system environment variable, the question will be solved.
I have the same issue and flutter upgrade --force fixed the problem.
Note: re-run the command flutter pub get after upgrading your flutter version.
So here are some options to consider in solving this issue:
If you have tried the above solutions and it didn't work, then
You probably have issues with your flutter SDK and need to fix that first. You have changes in your flutter SDK.
To fix this, kindly cd into your flutter directory. For instance D:\repo\flutter
Find out what git changes you have in this directory using git status
Use git add * to add these changes (files) and then do git stash
To ensure that you're on the latest build from this channel, run flutter upgrade
You should be able to switch to any of your flutter channels
Stay safe. All the best
Maybe your Flutter SDK is not in the latest version. upgrade it by below command (and the documentation says, it is preferred to keep stable channel, upgrade to dev only if it essential)
flutter upgrade
I have resolved this by adding integration_test above test declaration, I saw this solution in official codelabs: https://codelabs.developers.google.com/codelabs/flutter-app-testing#2
As on pic:
I think this is a better way, than downgrading the plugin by using 'any' or changing flutter channel.
Inspect correctly your "pubspect.yaml" it's possible

Resources