Cannot do "flutter packages upgrade". I get socket error - gradle

I am trying to start a new flutter project, I followed the getting started guide, installed android studio, flutter sdk, got a device working, added flutter package to VScode. you can see my flutter doctor output here:
D:\Workspace\flutter_app>flutter doctor -v
[√] Flutter (Channel beta, v0.8.2, on Microsoft Windows [Version 6.1.7601],
locale en-US)
• Flutter version 0.8.2 at C:\src\flutter
• Framework revision 5ab9e70727 (4 weeks ago), 2018-09-07 12:33:05 -0700
• Engine revision 58a1894a1c
• Dart version 2.1.0-dev.3.1.flutter-760a9690c2
[√] Android toolchain - develop for Android devices (Android SDK 28.0.3)
• Android SDK at C:\Users\baib37302\AppData\Local\Android\sdk
• Android NDK location not configured (optional; useful for native profiling
support)
• Platform android-28, build-tools 28.0.3
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-
b06)
• All Android licenses accepted.
[√] Android Studio (version 3.2)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 29.0.2
• Dart plugin version 181.5616
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-
b06)
[√] VS Code (version 1.27.2)
• VS Code at C:\Users\baib37302\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 2.19.0
[√] Connected devices (1 available)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 8.1.0
(API 27) (emulator)
• No issues found!
I am working behind a corporate proxy, but I added this to environment variables: HTTP_PROXY : http://"user":"pass"#proxy:8080
As you can see, Everything looks great. The only issue is I cannot run the project, because running "Flutter run" starts executing "flutter packages get" which is not working due to a socket error when connecting to https://pub.dartlang.org. As you can see here:
D:\Workspace\flutter_app>flutter packages get
Running "flutter packages get" in flutter_app...
Got socket error trying to find package node_preamble at
https://pub.dartlang.org.
pub get failed (69) -- attempting retry 1 in 1 second...
This issue comes up when trying to run from android studio or vs code.
I even tried getting pubscpec.lock file from an example project to try to work around this issue, but that failed as running "flutter install" ends up with gradle error as you can see in:
Flutter crash report; please file at https://github.com/flutter/flutter/issues.
## command
flutter install
## exception
String: Exit code 1 from: D:\Workspace\flutter_app\android\gradlew.bat -v:
Downloading https://services.gradle.org/distributions/gradle-4.4-all.zip
Exception in thread "main" java.net.UnknownHostException: services.gradle.org
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:673)
at sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:173)
at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:264)
at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:367)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1138)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1032)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1546)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
at org.gradle.wrapper.Download.downloadInternal(Download.java:58)
at org.gradle.wrapper.Download.download(Download.java:44)
at org.gradle.wrapper.Install$1.call(Install.java:61)
at org.gradle.wrapper.Install$1.call(Install.java:48)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
at org.gradle.wrapper.Install.createDist(Install.java:48)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:128)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)

Related

I can't create virtual device through android studio, nor configure my phone with adb

Error Creating AVD
An error occurred while creating the AVD. See idea.log for details.
I use windows 11, latest version available today. I don't use android studio to program, I use VSCode and program with flutter, I haven't used this PC for a while, and now besides not being able to create an AVD (virtualization is enabled in the bios), I can't connect my cell phone to send it to it, this it returns to me in the terminal when I try to connect by wifi:
{path}\Sdk\platform-tools> ./adb pair 191.52.129.80:43883
Enter pairing code: 485667
* daemon not running; starting now at tcp:5037
* daemon started successfully
error: protocol fault (couldn't read status length): connection reset
When I connect by usb cable, it returns me this:
! Device RX8N207HSZK is not authorized.
You might need to check your device for an authorization dialog.
Since I already authorized everything and on my other computer it works.
Java version:
Picked up _JAVA_OPTIONS: -Xmx512M
java 17 2021-09-14 LTS
Java(TM) SE Runtime Environment (build 17+35-LTS-2724)
Java HotSpot(TM) 64-Bit Server VM (build 17+35-LTS-2724, mixed mode, sharing)
Flutter version:
Flutter 2.10.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 7e9793dee1 (31 hours ago) • 2022-03-02 11:23:12 -0600
Engine • revision bd539267b4
Tools • Dart 2.16.1 • DevTools 2.9.2
Below I will leave all flutter doctor information with the -v parameter:
[✓] Flutter (Channel stable, 2.10.3, on Microsoft Windows [version 10.0.22000.493], locale pt-BR)
• Flutter version 2.10.3 at C:\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 7e9793dee1 (31 hours ago), 2022-03-02 11:23:12 -0600
• Engine revision bd539267b4
• Dart version 2.16.1
• DevTools version 2.9.2
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
• Android SDK at C:\Users\pedro\AppData\Local\Android\sdk
• Platform android-32, build-tools 32.1.0-rc1
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version openjdk version "11.0.11" 2021-04-20
• All Android licenses accepted.
[✓] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[✗] Visual Studio - develop for Windows
✗ Visual Studio not installed; this is necessary for Windows development.
Download at https://visualstudio.microsoft.com/downloads/.
Please install the "Desktop development with C++" workload, including all of its default components
[✓] Android Studio (version 2021.1)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version openjdk version "11.0.11" 2021-04-20
[✓] VS Code (version 1.64.2)
• VS Code at C:\Users\pedro\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.36.0
[✓] Connected device (3 available)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [version 10.0.22000.493]
• Chrome (web) • chrome • web-javascript • Google Chrome 99.0.4844.51
• Edge (web) • edge • web-javascript • Microsoft Edge 98.0.1108.62
! Device RX8N207HSZK is not authorized.
You might need to check your device for an authorization dialog.
[✓] HTTP Host Availability
• All required HTTP hosts are available
! Doctor found issues in 1 category.
In short: I'm desperate for a solution, I've already tried deleting android studio from the locations I knew ('user/{user_name}/Android', 'AppData/local/Android' and 'AppData/roaming/Google/AndroidStudio') as well as android studio folder in program files and reinstall it, I tried to reinstall flutter and java and also nothing, I hope I don't need to format my machine :'(
I managed to solve the problem in a bizarre way. I copied the '.android' folder from another working computer and pasted it into this one and it worked.

Error: Expected ios/Runner.xcodeproj but this file is missing

I am getting the issue after reinstall my Xcode from 13.2 beta version to 13.2.1 release version, by-mistake I have deleted my project build folder & runner.
Expected ios/Runner.xcodeproj but this file is missing. No application
found for TargetPlatform.ios. Is your project missing an
ios/Runner/Info.plist? Consider running "flutter create ." to create
one.
I also gone through it's suggestion
flutter create .
but still having the same issue. my flutter doctor -v result is
apple#apples-Mac-mini test_ios % flutter doctor -v
[✓] Flutter
(Channel stable, 2.8.1, on macOS 11.6.1 20G224 darwin-x64, locale
en-GB)
• Flutter version 2.8.1 at /Users/apple/Desktop/flutter_sdk/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 77d935af4d (12 days ago), 2021-12-16 08:37:33 -0800
• Engine revision 890a5fca2e
• Dart version 2.15.1
[✓] Android toolchain - develop for Android devices (Android SDK
version 31.0.0)
• Android SDK at /Users/apple/Library/Android/sdk
• Platform android-31, build-tools 31.0.0
• ANDROID_HOME = /Users/apple/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
• Xcode at /Users/apple/Downloads/Xcode.app/Contents/Developer
• CocoaPods version 1.11.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2020.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
[✓] Connected device (2 available)
• iPod touch (7th generation) (mobile) • A7FF5F55-96CF-4DD4-9790-6162A82AA0B7 • ios •
com.apple.CoreSimulator.SimRuntime.iOS-15-2 (simulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 96.0.4664.110
• No issues found!
also I have created the new flutter project from Android Studio but unfortunately it is also not containing the same file.
I had the same issue after I manually deleted xcode profile using xcode IDE.
Please try the following:
Create a new flutter project.
Run the project - confirm its in good working order (you will see xcode compilation)
3)I copied all files under ios folder of the new project to my current one & it worked like a charm.
Good luck.
Unfortunately I could not get solution online I had to try my own ways and it worked. This error occurs when you update Xcode. For me I downloaded the Xcode beta, and installed it then recreated the project
. You can extract if you have a backup. Then run Xcode beta simulator. That all. ALL the best.
Some how i found the files Runner.xcodeproj and Runner.xcworspace in bin and restoring them back solved my issues!

X Code failing to archive flutter project

I have a flutter projects which runs smoothly in IOS simulators. But when I try to build archive it keeps failing with error
sent 417348630 bytes received 120 bytes 166939500.00 bytes/sec
total size is 417297279 speedup is 1.00
/Users/blb/Library/Developer/Xcode/DerivedData/Runner- grwmtliatfewpwgywhanjiefmgxn/Build/Intermediates.noindex/ArchiveIntermediates/Runner/InstallationBuildProductsLocation/Applications/Runner.app/Frameworks/App.framework/App: errSecInternalComponent
Command PhaseScriptExecution failed with a nonzero exit code
I have all the developer certificates and accounts etc. Tried every solution I found in internet but didn't worked.
blb#Bhargavs-MacBook-Pro customer % flutter doctor -v
[✓] Flutter (Channel beta, 1.25.0-8.3.pre, on macOS 11.1 20C69 darwin-x64, locale en-IN)
• Flutter version 1.25.0-8.3.pre at /Users/blb/Development/flutter
• Framework revision 5d36f2e7f5 (3 days ago), 2021-01-14 15:57:49 -0800
• Engine revision 7a8f8ca02c
• Dart version 2.12.0 (build 2.12.0-133.7.beta)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/blb/Library/Android/sdk
• Platform android-30, build-tools 30.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.3, Build version 12C33
• CocoaPods version 1.10.1
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
[✓] VS Code (version 1.51.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.16.0
[✓] Connected device (3 available)
• Redmi Note 7 Pro (mobile) • a682ccfc • android-arm64 • Android 10 (API 29)
• iPhone SE (2nd generation) (mobile) • 2FEBA15E-A172-4FF2-B915-ECF8D222F57A • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 87.0.4280.141
• No issues found!
It might be related to a singing issue.
I was facing the same issue where the app was forking fine when I did
flutter run // Working
But when I tried creating the ipa for distribution, it used to give me an archive failed error.
flutter build ipa // Error
I tried to do flutter clean, xcode clean and all the other different things but nothing worked.
So, I tried with a sample app, and then ran flutter build ipa which asked me to setup my certificate on that project which I did and it worked fine.
When, I came back to my original project, and it also started working. So, it was definitely some certificate issue which was leading to all these problems. Using a sample project, helped resolve it.

Display an error while debug the flutter App in vscode

I can't debug my Flutter App in Vscode , and DEBUG CONSOL returned :
Unable to locate a development device; please run 'flutter doctor' for
information about installing additional components.
I can show my emulator after run this :
flutter emulators
And i can run it :
flutter emulators --launch 4.7_WXGA_API_22
flutter doctor -v :
[✓] Flutter (Channel stable, v1.7.8+hotfix.4, on Linux, locale en_US.UTF-8)
• Flutter version 1.7.8+hotfix.4 at /home/ZZZ/Dev/Flutter/flutter
• Framework revision 20e59316b8 (10 days ago), 2019-07-18 20:04:33 -0700
• Engine revision fee001c93f
• Dart version 2.4.0
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /media/ZZZ/B0B8B687B8B64C1A/Dev_ubuntu/android-sdk-linux/
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• ANDROID_HOME = /media/ZZZ/B0B8B687B8B64C1A/Dev_ubuntu/android-sdk-linux/
• Java binary at: /usr/local/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b16-5323222)
• All Android licenses accepted.
[✓] Android Studio (version 3.4)
• Android Studio at /usr/local/android-studio
• Flutter plugin version 37.1.1
• Dart plugin version 183.6270
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b16-5323222)
[✓] VS Code (version 1.36.1)
• VS Code at /usr/share/code
• Flutter extension version 3.2.0
[✓] Connected device (1 available)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 5.1.1 (API 22) (emulator)
• No issues found!
My operating system is Ubuntu 18.04 and i want to use emulator for debug , please help me.
You are having 3 options:
You can open your emulator in Android Studio and after that debug your application from VSCode.
You can also check whether adb(Android debugger bridge) is installed in your machine or not.
Or else you can run your application in a real device.
My problem was solved by this command
flutter config --android-sdk <sdk-location>
link

Error running flutter app in both Android studio and Xcode

I am facing this issue after I have switched from beta channel to master and whenever I try to run my Flutter application in either android studio or Xcode I get this error:
2018-09-20 15:18:16.711602+0100 Runner[7370:3358571] ../../third_party/dart/runtime/vm/kernel_binary.cc: 39: error: Invalid kernel binary format version (found 5, expected 7)
2018-09-20 15:18:16.711665+0100 Runner[7370:3358571] Dumping native stack trace for thread 9e03
2018-09-20 15:18:16.735476+0100 Runner[7370:3358571] [0x00000001056f5d64] dart::Profiler::DumpStackTrace(void*)
2018-09-20 15:18:16.735963+0100 Runner[7370:3358571] [0x00000001056f5d64] dart::Profiler::DumpStackTrace(void*)
2018-09-20 15:18:16.736001+0100 Runner[7370:3358571] [0x0000000000000000] Unknown symbol
2018-09-20 15:18:16.737556+0100 Runner[7370:3358571] [0x00000001055f7378] dart::kernel::Program::ReadFromBuffer(unsigned char const*, long, bool)
2018-09-20 15:18:16.737589+0100 Runner[7370:3358571] -- End of DumpStackTrace
This is my flutter doctor:
[✓] Flutter (Channel master, v0.9.3-pre.3, on Mac OS X 10.13.4 17E199, locale en-GB)
• Flutter version 0.9.3-pre.3 at /Users/heyab/flutter
• Framework revision 8b5af14f24 (17 hours ago), 2018-09-19 15:42:51 -0700
• Engine revision 2e8e96fad1
• Dart version 2.1.0-dev.4.0.flutter-4eb879133a
[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
• Android SDK at ....
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-27, build-tools 27.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
• All Android licenses accepted.
[✓] iOS toolchain - develop for iOS devices (Xcode 9.4.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 9.4.1, Build version 9F2000
• ios-deploy 1.9.2
• CocoaPods version 1.5.3
[✓] Android Studio (version 3.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 24.2.1
• Dart plugin version 173.4700
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
[✓] Connected devices (2 available)
• No issues found!
Can anyone help me please?
I have managed to fix this issue: by going to Build Phases -> Run Script and add:
/bin/sh "$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" build
and then untick "run script only when installing" -> Code Cleanup -> Build Project -> And perfectly working now! :)

Resources