having trouble to run my first flutter app
Solution 1
I'm gonna say exactly how I overcome this issue .some steps might not be necessary but i did all of this :
- unistall flutter and android studio
- install the lastest version of both (android studio and flutter )
- then add
maven { url 'http://download.flutter.io' }
in your build.gradle file
-
then change compile and target sdk version to 29 (just find them and replace 29 with 28 ) C:\Users\$USER\AndroidStudioProjects\$projectname\android\app\build.gradle like this
compileSdkVersion 29 targetSdkVersion 29
this is how it got solved for me . i hope it works for you guys too .
Solution 2
It seems your Gradle files are damaged.
Here's what you need to do:
open $HOME/.gradle/wrapper/dists and delete gralde-xxx-all . then execute command: flutter run again.
More info here.
Solution 3
Go into your Project folder and in the
gradle wrapper gradle-wrapper
change the number from:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
Comments
-
aiden021 over 1 year
I'm facing an error when i try to run a flutter project in android studio or in command line with flutter run it gives me this error
Exception in thread "main" java.net.SocketException: Unexpected end of file from server at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:851) at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:678) at sun.net.www.protocol.http.HttpURLConnection.doTunneling(HttpURLConnection.java:2055) at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:183) at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1564) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:263) 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)
Finished with error: Gradle task assembleDebug failed with exit code 1
the output of flutter doctor -v
[√] Flutter (Channel stable, v1.12.13+hotfix.9, on Microsoft Windows [Version 10.0.17134.1425], locale en-US) • Flutter version 1.12.13+hotfix.9 at C:\src\flutter • Framework revision f139b11009 (5 weeks ago), 2020-03-30 13:57:30 -0700 • Engine revision af51afceb8 • Dart version 2.7.2
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3) • Android SDK at C:\Users\win10\AppData\Local\Android\android-sdk • Android NDK location not configured (optional; useful for native profiling support) • Platform android-29, build-tools 29.0.3 • ANDROID_HOME = C:\Users\win10\AppData\Local\Android\android-sdk • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04) • All Android licenses accepted.
[√] Android Studio (version 3.6) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin version 45.1.1 • Dart plugin version 192.7761 • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
[√] VS Code, 64-bit edition (version 1.34.0) • VS Code at C:\Program Files\Microsoft VS Code • Flutter extension version 3.2.0
[√] Connected device (1 available) • Android SDK built for x86 • emulator-5554 • android-x86 • Android 8.1.0 (API 27) (emulator)
• No issues found!
PS: and i had another issue a while back so i changed flutter.gradle file like this
buildscript { repositories { google() jcenter() mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:3.5.0' }
-
aiden021 about 4 yearsUsing hardware rendering with device Android SDK built for x86. If you get graphics artifacts, consider enabling software rendering with "--enable-software-rendering". Launching lib\main.dart on Android SDK built for x86 in debug mode... Running Gradle task 'assembleDebug'... (This is taking an unexpectedly long time.) i just did what you said and it stuck here
-
Gazihan Alankus about 4 yearsI had this happen to me before. You either need to clean more stuff in your HDD (this was my case) or you need to fix some network settings. Here are 4 helpful links. stackoverflow.com/questions/59516408/… github.com/flutter/flutter/issues/27310 github.com/flutter/flutter/issues/47392 stackoverflow.com/questions/58238026/…
-
Jeremy Caney about 4 yearsTelling someone not to use the language or framework they’re asking a question about doesn’t answer the question.
-
aiden021 about 4 yearsyeah that s true i found the solution
-
Jeremy Caney about 4 yearsThank you! That’s a much improved answer. Also, I had missed that you were the OP when I left that comment, so mistook your frustration for snark. Regardless, the update is appreciated.