티스토리 뷰

반응형

Stack Overflow에 자주 검색, 등록되는 문제들과 제가 개발 중 찾아 본 문제들 중에서 나중에도 찾아 볼 것 같은 문제들을 정리하고 있습니다.

Stack Overflow에서 가장 먼저 확인하게 되는 가장 높은 점수를 받은 Solution과 현 시점에 도움이 될 수 있는 가장 최근에 업데이트(최소 점수 확보)된 Solution을 각각 정리하였습니다.

 

아래 word cloud를 통해 이번 포스팅의 주요 키워드를 미리 확인하세요.

How to solve SocketException: Failed host lookup: 'www.xyz.com' (OS Error: No address associated with hostname, errno = 7)

SocketException: Failed host lookup: '[www.xyz.com](http://www.xyz.com)' (OS Error: No address associated with hostname, errno = 7) 오류를 해결하는 방법

 문제 내용 

Whenever I try to do an http call after about 20 seconds I get in the console the following error:

약 20초 후에 HTTP 호출을 시도하면 콘솔에 다음과 같은 오류가 표시됩니다:
E/flutter ( 8274): [ERROR:flutter/shell/common/shell.cc(184)] Dart Error: Unhandled exception:
E/flutter ( 8274): SocketException: Failed host lookup: 'flutter-project-xxxxx.firebaseio.com' (OS Error: No address associated with hostname, errno = 7)

 

This error happens for every method and every route I call through the app http package.

이 오류는 앱 http 패키지를 통해 호출하는 모든 메소드와 라우트에 대해 발생합니다.

 

I'm developing a flutter app on Windows, using an AVD virtual device from Android Studio.

저는 안드로이드 스튜디오에서 AVD 가상 장치를 사용하여 윈도우에서 플러터 앱을 개발하고 있습니다.

 

Versions:

버전:
  http: ^0.12.0+1
  flutter: 1.0

 

Cases:

다음과 같은 상황

 

  1. From home or though tethering from my phone: connectivity works fine on every part of the virtual device
  2. From my work network (behind the firewall):
1. 집에서 또는 핸드폰 테더링을 통해: 가상 기기의 모든 부분에서 연결이 잘 작동합니다.
2. 근무 네트워크(방화벽 뒤)에서:

 

Only with Android Web View, I can browse the internet without any problem (i can even call the same url, I use in the code and it works). I get a connection error when using any other application (Chrome, Google Play, ecc...) in the virtual device, and specifically the "SocketException", when testing my app.

안드로이드 웹 뷰만 사용하는 경우 인터넷을 문제없이 브라우징할 수 있습니다(코드에서 사용하는 동일한 URL을 호출하여 동작도 합니다). 그러나 가상 기기에서 다른 애플리케이션(Chrome, Google Play 등)을 사용할 때 연결 오류가 발생하며, 특히 내 앱을 테스트할 때 "SocketException"이 발생합니다.

 

What is the difference between the calls coming from that app? Is there a way to route my app calls the same way as the ones in the webview?

그 앱에서 오는 호출과 다른 점은 무엇인가요? 웹뷰에서 사용하는 것과 같은 방법으로 내 앱 호출을 경로 지정할 수 있는 방법이 있을까요?

 

Thanks!

감사합니다!

 

 

 

 높은 점수를 받은 Solution 

Adding internet permission is not only a solution.
You also have to make sure that you are online whether it is mobile or emulator

인터넷 권한을 추가하는 것만으로 문제가 해결되는 것은 아닙니다. 모바일 또는 에뮬레이터에서 온라인인지 확인해야 합니다.

 

  1. Make sure you are online whether it is mobile or emulator
  2. Make sure you have given internet permission in your app's android/app/src/main/AndroidManifest.xml
  3. <uses-permission android:name="android.permission.INTERNET"/>
1. 앱이 실행되는 환경에서 온라인인지 확인하세요. 실제 모바일 기기에서 실행하거나 에뮬레이터에서 실행 중인지 확인하세요.
2. 또한, 앱의 android/app/src/main/AndroidManifest.xml 파일에서 인터넷 권한이 허용되어 있는지 확인하세요.
3. <uses-permission android:name="android.permission.INTERNET"/> 퍼미션을 정의하세요.

 

 

 

 가장 최근 달린 Solution 

Make sure you have added the in android/app/src/main/AndroidManifest.xml

android/app/src/main/AndroidManifest.xml에 아래를 추가했는지 확인하세요.
<uses-permission android:name="android.permission.INTERNET" />

enter image description here

 

 

출처 : https://stackoverflow.com/questions/54551198/how-to-solve-socketexception-failed-host-lookup-www-xyz-com-os-error-no-ad

반응형
댓글
공지사항
최근에 올라온 글