2

I'm attempting to run this Flutter To-Do list app in Visual Studio Code:

https://github.com/LiveLikeCounter/Flutter-Todolist

And I'm encountering this error:

I/flutter (30973): Observatory server failed to start after 11 tries
I/flutter (30973): Could not start Observatory HTTP server:
I/flutter (30973): SocketException: Failed to create server socket (OS Error: Operation not permitted, errno = 1), address = 127.0.0.1, port = 0
[38;5;244mI/flutter (30973): #0      _NativeSocket.bind  (dart:io-patch/socket_patch.dart:736:7)[39;49m
I/flutter (30973): <asynchronous suspension>
[38;5;244mI/flutter (30973): #1      _RawServerSocket.bind  (dart:io-patch/socket_patch.dart:1394:26)[39;49m
[38;5;244mI/flutter (30973): #2      _ServerSocket.bind  (dart:io-patch/socket_patch.dart:1676:29)[39;49m
[38;5;244mI/flutter (30973): #3      ServerSocket._bind  (dart:io-patch/socket_patch.dart:1667:26)[39;49m
[38;5;244mI/flutter (30973): #4      ServerSocket.bind  (dart:io/socket.dart:382:27)[39;49m
[38;5;244mI/flutter (30973): #5      _HttpServer.bind  (dart:_http/http_impl.dart:2701:25)[39;49m
I/flutter (30973): #6      HttpServer.bind (dart:_http:229:19)
[38;5;244mI/flutter (30973): #7      Server.startup.poll  (dart:vmservice_io/vmservice_server.dart:410:36)[39;49m
I/flutter (30973): <asynchronous suspension>
I/flutter (30973): #8      Server.startup.poll (dart:vmservice_io/vmservice_server.dart)
[38;5;244mI/flutter (30973): #9      Server.startup  (dart:vmservice_io/vmservice_server.dart:422:23)[39;49m
I/flutter (30973): <asynchronous suspension>
I/flutter (30973): #10     main (dart:vmservice_io:262:12)

I'm running Windows 10 Home.

After doing some digging on the issue I have tried:

No success here.

On all my debug, main and profile AndroidManifest.xml files I have:

...
<uses-permission android:name="android.permission.INTERNET" />
...

Except on the main one I have:

...
<uses-permission android:name="android.permission.INTERNET" android:maxSdkVersion="18" />
...

On my pubsec.yaml file I have:

...
environment:
  sdk: ">=2.2.0 <3.0.0"
...

On my android/app/build.gradle file I have:

...
android {
    compileSdkVersion 28
...

Flutter Doctor:

[√] Flutter (Channel stable, v1.17.1, on Microsoft Windows [Version 10.0.18363.836], locale en-US)
    • Flutter version 1.17.1 at C:\SDK\FlutterSDK\flutter
    • Framework revision f7a6a7906b (4 weeks ago), 2020-05-12 18:39:00 -0700
    • Engine revision 6bc433c6b6
    • Dart version 2.8.2


[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at C:\Users\y_cha\AppData\Local\Android\sdk
    • Platform android-29, build-tools 29.0.3
    • 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.8052
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)

[√] VS Code (version 1.45.1)
    • VS Code at C:\Users\y_cha\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.11.0

[√] Connected device (2 available)
    • SM G975F                  • R58M43954DX   • android-arm64 • Android 10 (API 29)
    • Android SDK built for x86 • emulator-5554 • android-x86   • Android 10 (API 29) (emulator)

• No issues found!

Gradle version:

distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip

This issue happens on both the android emulator and my physical device.

I have seen this issue show up in many searches, but I haven't seen a definitive solution.

Anyone with any knowledge of a solution to this please help.

Thanks.

Raul Marquez
  • 948
  • 1
  • 17
  • 27

3 Answers3

3

I was missing \debug\AndroidManifest.xml Content:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.my_project">
    <!-- Flutter needs it to communicate with the running application
         to allow setting breakpoints, to provide hot reload, etc.
    -->
    <uses-permission android:name="android.permission.INTERNET"/>
</manifest>

(replace my_project with your project)

The file content was identical to \profile\AndroidManifest.xml

mortenma71
  • 1,078
  • 2
  • 9
  • 27
0

Well, I didn't actually fix any configurations, but I did get around the problem.

I created a new demo app with the Flutter command:

flutter create demoapp

This creates the stock counter app.

So I just copied all relevant files and assets to the demo app and it finally ran.

Not sure how to feel about this but I think it'll be something I'll be encountering on a regular basis.

Also I think creating a Flutter project in one IDE and then openning it in another creates among other things these types of launch/install issues.

Raul Marquez
  • 948
  • 1
  • 17
  • 27
0

I was seeing this problem on Android 10, but not Android 8.1. What fixed this for me was adding:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

It was originally using android.permission.ACCESS_COURSE_LOCATION.

spekary
  • 408
  • 5
  • 10