Written by Gibran
June 30, 2020
Context: We are developing the first mobile application for the company in Android Studio with the Flutter framework, which will allow us to publish the application for both IOS and Android in record time, but an error prevents us from installing the packages that we will use. “pub get failed (69)”….
Greetings! If you came here you are probably in a similar scenario, or you like technology blogs too much. This error occurs when we work in corporate networks through proxy connections, which usually avoid certain connections that are necessary for our Android Studio to download the packages for our application.
The error can be replicated when trying to run our application, then the console would show us the following message in loop until we finish dart.exe:
Running “flutter pub get” in your_app…
Could not resolve URL “https://pub.dartlang.org“.
pub get failed (69) — attempting retry 1 in 1 second…
Below I share some solutions that have served me or could have served me on this issue. It is likely that your problem will be solved with the first one, but you could also have my same luck and find that the last one I offer is the only option.
1.- Request a free access node.
This is the simplest and most diplomatic solution, ask your network administrator for free Internet access, this way you can work comfortably.
It is common that in companies, free nodes are granted for a limited time and always under justified request. You can mix this proposal and the 3rd or 4th mentioned in this article to save yourself the request for new node uses in new projects with packages that you already have downloaded.
In my case, I wanted to avoid lifting a request every time I update or download a new package, which was a bad decision, since it led me to know the following alternatives. Make sure that the Android Studio configuration for connection via proxy is deactivated and preferably it has never been configured, more details of why and how in the next point.
2.- Configure the proxy connection of Android Studio.
Use this option only in case the free node cannot be provided.
To be able to access the Internet from Android Studio through proxy, go to File> Settings; then inside the popup: Appearance & Behavior > System Settings > HTTP Proxy. Preferably select the Manual configuration and enter the necessary data. Do not forget to click “Apply” to make the changes.
Here is a screenshot of the popup:
In point 1 I had mentioned avoiding using this configuration, the reason is that I experienced the following: At first I requested free internet access to get my packages, but after several requests, I was recommended to enable my connection via proxy so as not to depend on attention to requests. So I proceeded and was able to actually download some packages, but not all, since the proxy server had its own security rules. After this I asked for the free node again and deactivated the proxy configuration, but to date Android Studio continues to try to access through the proxy despite having it disabled and free internet access. Therefore I do not recommend it, since it only allows the download of some packages.
3.- Get the packages by ‘flutter get’ in an open network through your corporate workstation.
This solution is only possible if your workstation is portable.
Step 1: Take your equipment home to an open network site.
Step 2: Go to your pubspec.yaml file and click the “Packages get” link at the top right of the preview.
Step 3: When the process is complete, you can return to your workplace and enjoy your packages.
4.- Run ‘flutter get’ on an open network through another computer and then import the packages to your corporate computer.
If you have no way to get your corporate computer to a friendly network, you will need to get your packages on another computer. This was my case, since as I mentioned, the proxy settings are cursed and I could not disable it. So I do the following:
Step 1: On my personal computer, I add my packages to pubspec.yaml (This can be in a new project or in a copy of the original)
Step 2: I get my packages using the “Packages get” button or I run my application to get them automatically as part of the compilation process.
Step 3: In a browser window, I go to the “build” folder of my project.
Step 4: There are the folders of the packages.
Note: we do not need all the content, only the folders of the packages, which we can identify by name, Here is a screenshot of my folder:
Step 5:I copy all the folders of my packages (For my example, they would be all the folders except “app“) and paste them in the build folder of the project that I have in my corporate computer.
Step 6: In Android Studio terminal, I run:
<FLUTTER_SDK_ROUTE>flutterbinflutter.bat pub get –offline
And ready.
From this moment I have my packages installed and I can continue my development.
Conclusion :
The truth is a headache to develop from a closed network, not only using Flutter, but with any framework that downloads packages. The fourth solution proposed here may seem problematic due to having to perform operations on another computer and on another network, but it should only be done when there is a new package or you want to update one. Hey!, you can even use github to make it quicker (May be subject to the network permissions of your workplace) For later projects, we will already have the packages on our computer and it will only be a matter of copying, pasting, and executing pub get –offline.
The best alternative will always be to ask for a free node, and believe me, it is better to ask for it every time you need it, to have to resort to a different computer to get the packages. If I have explained something here in a confusing way and a better explanation would help, do not hesitate to contact me and I will try to be more clear.
At the moment I say goodbye.
Peace and good!