How to install and run flutter without network connection? - flutter

I installed flutter on a machine with a network, all tests and commands ( doctor, create, test ) run without problems. Then he took the directory where flutter was located and transferred it to a machine without an Internet connection. But with any call to flutter, it goes into
Running "flutter pub get" in flutter_tools.."
And does not leave this process. If you run it with the -vv flag, you can see that there is Resolving dependencies... The --offline flag does not help. I also tried to take .config, .pub-cache, .flutter from the machine where there is a connection and transfer it to the working one, but this did not help either. The question is, is there anything else that can be dragged and dropped as a dependency, or is there another way to run flutter offline?
Both machines are running Debian 9.

As I thought, all this is possible. The problem is in the wrong paths. When transferring the flutter working directory to another PC, you need to make sure that the paths are identical. Because in *packages/flutter_tools/ files there are many links in files on paths that correspond to downloads from the first machine.
Total what needs to be done:
Update flutter and dart
Run flutter precache
Copy the entire directory where flutter is located and ~$HOME/.pub-cache
Create the same path on the new machine and transfer the files.
Perform all necessary operations with the --offline flag

Related

Bazel not running flutter correctly

I'm trying to execute a flutter command using bazel. This is my BUILD.bazel file:
genrule(
name = "flutter_build",
srcs = [
"//:root_filegroup"
],
outs = ["out.txt"],
cmd = "flutter build ipa --export-method development"
)
The command flutter build ipa --export-method development works perfectly if I run it directly in my iterm, but for some reason the same command in bazel returns a permission error:
Flutter failed to open a file at "/Users/rlanhe/tools/flutter/flutter/bin/cache/lockfile".
Please ensure that the SDK and/or project is installed in a location that has read/write permissions for the current user.
Try running:
sudo chown -R $(whoami) /Users/rlanhe/tools/flutter/flutter/bin/cache/lockfile
Well, doesn't make sense to me, since that folder already have correct permission and I'm able to run the command outside bazel.
Integrating Flutter/Dart and Bazel is likely a large amount of work.
There's an issue here about it:
https://github.com/flutter/flutter/issues/19680
And it looks like there are some dart rules here:
https://github.com/cbracken/rules_dart
The immediate issue you're running into is that Bazel runs each action (i.e. build step) in a sandbox, so unless an input to the action is declared, it's not going to be in the sandbox. You can maybe get further by adding tags = ["no-sandbox"] to the genrule, (see https://bazel.build/reference/be/common-definitions#common.tags).
This is essentially running one build system inside another, and this isn't going get the caching and incrementality benefits of Bazel, because Bazel has no insight into what happens inside the genrule. Unless you have some higher-level plans to integrate this into a larger repository that uses Bazel, there isn't much benefit here compared to running flutter directly or in a shell script.

Unable to access flutter doctor from my flutter console [duplicate]

When I run in terminal flutter pub get is stuck it's showing
OS MacOS Catalina 10.15.3
Got TLS error trying to find package launch_review at https://pub.dartlang.org.
pub get failed (server unavailable) -- attempting retry 1 in 1 second...
Got socket error trying to find package launch_review at https://pub.dartlang.org.
pub get failed (server unavailable) -- attempting retry 2 in 2 seconds...
Got TLS error trying to find package launch_review at https://pub.dartlang.org.
pub get failed (server unavailable) -- attempting retry 3 in 4 seconds...
Got socket error trying to find package launch_review at https://pub.dartlang.org.
pub get failed (server unavailable) -- attempting retry 4 in 8 seconds...
Got socket error trying to find package launch_review at https://pub.dartlang.org.
Quick fixes before explanation:
Restart your router! Works for me several times.
Make sure your network is not behind a proxy
Make sure you can ping to pub.dev without any packet loss
Try to close all of your dart.exe processes before retying to perform the flutter pub get
Try to delete an existing package from your pubspec.yaml and re-get it to see if it works
Try to manually add the package to your project
So, I had (and sometime still having) the same issue. I've analyzed it and came to a conclusion that the package download manager and the server that hosts those packages aren't reliabe at all. Very small packages might just successfully be imported with "flutter pub get", whereas big ones might last forever to download. This is definately a networking issue, on either yours or their side.
Just for verificatioin that we are indeed experiencing the same issue:
open your cmd (no matter t OS) and run: ping -t pub.dev .Now, if you see those inconsitent replies from the server, it means there's something wrong with the network (yours or their side). This looks something like this:
Open up your task manager and look for the latest dart.exe task (it should be invoked the moment you flutter pub get. This task is the package that is being downloaded. If you see the process size never exceeding a certain size, and the get command is still stuck, it only indicates a network issue and the package might never be downloaded successfully. For example, my attempts to get the carousela_flutter 1.4.1 package ended up with a halted process size of around 60mb, looks this this:
If you wait for a relatively large amount of time (10 minutes I would say is enough) and the connectivity issue is still not resolved, you will see the following msg from flutter:
"Process finished with exit code 0".
I suggest you try another time or maually add the package.
p.s: it doesn't happen with all of the packages and from my investigation is seems to be related to the size of it. e.g, I managed to get the carousela_flutter 0.7.0 package, but the 1.4.1 failed.
In my case, The host of my ISP was blocked so it could not get the package and it was showing pub get failed (server unavailable) -- attempting retry 1 in 1 second...
So I turn on my VPN and tried once again and this time it was a success
If its a git error, use this command:
git config --global url."https://".insteadOf git://
More info here
502 Bad Gateway trying to find package package_name at https://pub.dartlang.org.
If you click on the link, you'll find that the website is down. The same is also applied to https://pub.dev/.
I´ve solved it on my Windows machine.
After many tries from answers in many discussions out there, I tried a lot of stuff, like:
Restarting the machine
Deleting the cache folder (the dart-sdk download may be restarted)
Adding dart-sdk in the Environment Variable Path
X:\Dev\Flutter\bin\cache\dart-sdk\
Adding dart-sdk´s bin folder in the Path variable (for both Environment and User Variables) (desperate action, I know)
X:\Dev\Flutter\bin\cache\dart-sdk\bin
And still didn´t work.
BUT... I´ve found on this thread something about a proxy problem.
Then I´ve decided to try it out on my Windows machine, and it worked (finally).
Try typing this on Power Shell:
$Env:https_proxy="your.proxy.here:8080"
Then try flutter doctor again
hmm, i know how frustrating it can be trying to solve the issue, the best solution to this is to use vpn and connect to another server. this way i was able to solve the problem without stress
As said it might be something that has to do with your network....
Disconnecting and reconnecting fixed mine.
Make sure no firewall is blocking it.
Check for Internet connectivity too. Search your browser, don't rely on the windows wifi symbol.
For me, KIS (Kaspersky) was blocking pub.bat.
If that is the case please also check---- Flutter, dart, android studio, Gradlew.bat, sdkmanager.bat, adb.exe, qemu-systems, emulator-check and google for any blockage. (just search in firewall settings).
In my case it was my virus program (AVG AntiVirus' Web Shield) that suddenly caused pub get to fail.
Because restaurant depends on flutter any from sdk which doesn't exist (unknown SDK "flutter"), version solving failed
fix proplem
done
change this package
this path prev last
path_provider_windows:file:///C:/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.0.5/lib/
change path fluatter plus /all
path
path_provider_windows:file:///C:/all/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-2.0.5/lib/
its ok
thanks
I was able to resolve it by using Visual Studio Debuggable Package Manager PowerShell, on your system open visual studio debuggable package manager and then type in flutter doctor it will resolve it within seconds
make sure there is no typo in pubpspec.yaml check it on here https://stackoverflow.com/a/72198419/8122500

Flutter Windows Desktop app gets stuck on white screen after msix installation

Background
I just developed my first flutter desktop app for a windows machine. The app is working fine while developing/debugging it, but I am trying to test it as an application in release mode.
What’s done
I created an msix using pub msix.
For signing, I have tried both my
own certificate and the test certificate that comes with msix
packages by default.
I have tried both stable and beta channels.
Actual Problem
When I install the app on the other system (or even on the actual system where I debugged the app). I can install the msix setup successfully I can see my app listed in the apps, but when I try to open it, it is stuck on a blank/white screen. There is no UI rendered. And if I try to maximize the window, it goes to App not responding state.
Any help will be really appreciated.
Thanks in advance.
Update / New Finding
After going through the links provided by Yehuda Kremer and pulling my hair for a few days, I found the answer in this tweet
https://twitter.com/FilledStacks/status/1436280577439715338?s=20
So the main issue is that app is using some absolute paths that don't work on other machines (after release)
1- My app was using a database, so I have made sure that that database path is relative to the application document directory.
2- Now the build is also referring to some dependencies and their paths are also absolute. I have noticed a flag CMAKE_INSTALL_LOCAL_ONLY in the cmake_install.cmake but that flag is not being set anywhere.
Here is the log of flutter build windows -v
https://pastebin.com/LAeshUMY
-- Now I am looking for a proper way to convert all the paths to relative so that the build is ready for installation on different machines, instead of local installation only.
I have found the solution.
The main problem was that the app was looking for some dependencies and it was unable to find them. As mentioned here.
The reason for not finding that in release mode can be one of the following,
You are using some dll (package that depends on a dll) that is available on a specific path in your system, but when you are release the app that (absolute) path is not valid anymore.
You are adding some asset with absolute path (that is only applicable to your system).
Solution:
If it is a dll, you should be adding that to the release folder. In my case it was sqlite3.dll
If it is some other asset then you should always use the relative path.
You mentioned msix package, let see if the problem is in the app or in the packaging process
run flutter build windows without the flutter pub run msix:create, then run the created .exe file to see if its work.
btw this issue mention here: https://github.com/flutter/flutter/issues/74507
and here (the 'maximizing' problem): Black screen appears on maximizing and minimizing flutter desktop app

Flutter error: Unable to locate gradlew script

I can't run all of my flutter apps, because in the console appears everytime this error message:
Downloading Gradle Wrapper... 1,2s
Launching lib\main.dart on SM G960F in debug mode...
Running Gradle task 'assembleDebug'...
Finished with error: Unable to locate gradlew script. Please check that C:\Users\...\android\gradlew.bat exists or that C:\Users\...\android can be read.
I try to fix this problem more than ten hours and don't find a solution.
I will advise you to check your pc properly for unwanted programs. Something is preventing your pc from running the Gradle. I had the same issue only to realize that antivirus was installed on my pc alongside a cd burner that I just installed. Check for any antivirus that might be preventing Gradle from running.
I also faced the same error initially. While creating a flutter application from scratch I just ran the default flutter application which is a counter app in a flutter. I faced the same issue at first. If you are in this same context as described earlier the following could be the solution
1.Java 8 is more suitable for the flutter/android development. The next versions of java have some exceptions. I used the Java 14 and stuck at this issue for some time
The next could be the JAVA_HOME path in your environment variables. If it is not provided the set the JAVA_HOME path.
Run flutter --doctor and check the requirements if satisfied like Android SDK is updated or not, upgrade flutter if required. In some cases having good Internet connection also plays a role in this issue some times.
These are the major points to be satisfied in order to get rid of this error. Mostly this could be the a solution or part of it.
The error suggests that something is preventing gradle to run properly on your machine. Check whether you have any unwanted programs or anti-virus on your machine running that might be preventing gradle to run. If so, remove or stop those programs / anti-virus and try again.
After that, delete the .gradle folder located here C:\Users\yourPcName\.gradle containing the unfinished file and try again . It will work now .
You can also manually download Gradle and map it in Android studio , Learn more with this article here .
Warning, the gradle versions change quickly, so make sure you manually
downloaded the exact version that flutter wanted to download and the
download failed. Download the gradle here and then replace it in the
gradle folder.
C:\Users\yourPcName\.gradle\wrapper\dists\gradle-x.x.x-all
If it still doesn't work,
Try to run flutter --doctor
From a console window that has the Flutter directory in the path (see above), run the following command to see if there are any platform dependencies you need to complete the setup:
C:\src\flutter> : flutter doctor
This command checks your environment and displays a report of the status of your Flutter installation. Check the output carefully for other software you might need to install or further tasks to perform (shown in bold text).
You can learn more here :
If flutter doctor itself doesn't work, then know that flutter is not installed on your machine (or you forgot to add it to the environment
variable).
I also faced this problem and I made something to run my app on android
tried to open anything on android files and android studio ask me if I want to open for editing android file in android studio then click on it and it will open android project then click run enter image description here

Why does flutter packages get fail? Same directory cloned from github but on one pc package get fail

Cloned from github a flutter repo onto Laptop(win10) and Desktop (win7) but on Desktop package get fail with error code 1
First two images show success on laptop pc.
See Below Desktop Fails to get packages.
Where should I correct this on Desktop?
However, I can create new app without any error on Desktop.
Please help, Thank you.
I deleted the two log files and also pubspec.lock file and run Flutter Get Packages. This Resolved the issue. This agonizing error ate up few hours.
I tried
flutter clean
flutter packages get
it worked