Unable to resolve host "www.imooc.com"

Unable to resolve host "www.imooc.com"

# 具体遇到的问题
不能解析URL
# 报错信息的截图


10/26 15:09:17: Launching 'internetdemo' on Pixel 3 API 28.

App restart successful without requiring a re-install.

$ adb shell am start -n "com.testapp.internetdemo/com.testapp.internetdemo.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -D

Waiting for application to come online: com.testapp.internetdemo | com.testapp.internetdemo.test

Waiting for application to come online: com.testapp.internetdemo | com.testapp.internetdemo.test

Connected to process 28645 on device 'Pixel_3_API_28 [emulator-5554]'.

Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.

W/ActivityThread: Application com.testapp.internetdemo is waiting for the debugger on port 8100...

I/System.out: Sending WAIT chunk

Connecting to com.testapp.internetdemo

Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.

W/ActivityThread: Application com.testapp.internetdemo is waiting for the debugger on port 8100...

I/System.out: Sending WAIT chunk

I/System.out: Debugger has connected

I/System.out: waiting for debugger to settle...

Connected to the target VM, address: 'localhost:50420', transport: 'socket'

I/chatty: uid=10098(com.testapp.internetdemo) identical 2 lines

I/System.out: waiting for debugger to settle...

I/System.out: waiting for debugger to settle...

I/chatty: uid=10098(com.testapp.internetdemo) identical 2 lines

I/System.out: waiting for debugger to settle...

I/System.out: debugger has settled (1379)

W/pp.internetdem: Accessing hidden method Landroid/graphics/drawable/Drawable;->getOpticalInsets()Landroid/graphics/Insets; (light greylist, linking)

    Accessing hidden field Landroid/graphics/Insets;->left:I (light greylist, linking)

    Accessing hidden field Landroid/graphics/Insets;->right:I (light greylist, linking)

    Accessing hidden field Landroid/graphics/Insets;->top:I (light greylist, linking)

    Accessing hidden field Landroid/graphics/Insets;->bottom:I (light greylist, linking)

W/pp.internetdem: Accessing hidden field Landroid/view/WindowInsets;->CONSUMED:Landroid/view/WindowInsets; (light greylist, reflection)

W/pp.internetdem: Accessing hidden method Landroid/view/View;->getAccessibilityDelegate()Landroid/view/View$AccessibilityDelegate; (light greylist, linking)

W/pp.internetdem: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (light greylist, reflection)

W/pp.internetdem: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (light greylist, reflection)

D/OpenGLRenderer: HWUI GL Pipeline

E/libc: Access denied finding property "ro.serialno"

W/pp.internetdemo: type=1400 audit(0.0:46): avc: denied { read } for name="u:object_r:serialno_prop:s0" dev="tmpfs" ino=5256 scontext=u:r:untrusted_app:s0:c98,c256,c512,c768 tcontext=u:object_r:serialno_prop:s0 tclass=file permissive=0

W/pp.internetdem: Accessing hidden method Landroid/graphics/Insets;->of(IIII)Landroid/graphics/Insets; (light greylist, linking)

V/StudioTransport: Agent command stream started.

V/StudioTransport: Transport agent connected to daemon.

D/: HostConnection::get() New Host Connection established 0xcda19b00, tid 28711

I/ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0

    android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasHDRDisplay retrieved: 0

I/OpenGLRenderer: Initialized EGL, version 1.4

D/OpenGLRenderer: Swap behavior 1

W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...

D/OpenGLRenderer: Swap behavior 0

D/EGL_emulation: eglCreateContext: 0xcda1f5c0: maj 2 min 0 rcv 2

D/EGL_emulation: eglMakeCurrent: 0xcda1f5c0: ver 2 0 (tinfo 0xe48cae40)

V/StudioTransport: Handling agent command 1200 for pid: 28645.

    JNIEnv not attached

W/Thread-2: type=1400 audit(0.0:47): avc: denied { write } for name="perfd" dev="dm-1" ino=36701 scontext=u:r:untrusted_app:s0:c98,c256,c512,c768 tcontext=u:object_r:shell_data_file:s0 tclass=dir permissive=0

D/EGL_emulation: eglMakeCurrent: 0xcda1f5c0: ver 2 0 (tinfo 0xe48cae40)

V/StudioTransport: Handling agent command 1200 for pid: 28645.

I/OpenGLRenderer: Davey! duration=776ms; Flags=0, IntendedVsync=24552326291777, Vsync=24552709625095, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=24552716494220, AnimationStart=24552716718220, PerformTraversalsStart=24552718643620, DrawStart=24552739273120, SyncQueued=24552866852020, SyncStart=24552998581220, IssueDrawCommandsStart=24552998835720, SwapBuffers=24553197402420, FrameCompleted=24553234148520, DequeueBufferDuration=2932000, QueueBufferDuration=4375000, 

I/Choreographer: Skipped 33 frames!  The application may be doing too much work on its main thread.

W/pp.internetdem: Accessing hidden field Ljava/nio/Buffer;->address:J (light greylist, reflection)

V/StudioTransport: Handling agent command 1200 for pid: 28645.

I/pp.internetdem: Background concurrent copying GC freed 21453(6MB) AllocSpace objects, 2(40KB) LOS objects, 50% free, 1768KB/3MB, paused 1.409ms total 102.863ms

W/pp.internetdem: Current dex file has more than one class in it. Calling RetransformClasses on this class might fail if no transformations are applied to it!

W/pp.internetdem: Current dex file has more than one class in it. Calling RetransformClasses on this class might fail if no transformations are applied to it!

W/pp.internetdem: Current dex file has more than one class in it. Calling RetransformClasses on this class might fail if no transformations are applied to it!

W/pp.internetdem: Current dex file has more than one class in it. Calling RetransformClasses on this class might fail if no transformations are applied to it!

D/NetworkSecurityConfig: Using Network Security Config from resource network_security_config debugBuild: true

W/System.err: java.net.UnknownHostException: Unable to resolve host "www.imooc.com": No address associated with hostname

W/System.err:     at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:157)

        at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:105)

W/System.err:     at java.net.InetAddress.getAllByName(InetAddress.java:1154)

W/System.err:     at com.android.okhttp.Dns$1.lookup(Dns.java:39)

W/System.err:     at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:175)

W/System.err:     at com.android.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:141)

W/System.err:     at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:83)

W/System.err:     at com.android.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:174)

W/System.err:     at com.android.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:126)

W/System.err:     at com.android.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:95)

W/System.err:     at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:281)

W/System.err:     at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:224)

W/System.err:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:461)

W/System.err:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:407)

W/System.err:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:538)

W/System.err:     at com.testapp.internetdemo.MainActivity.get(MainActivity.java:55)

W/System.err:     at com.testapp.internetdemo.MainActivity.access$000(MainActivity.java:17)

W/System.err:     at com.testapp.internetdemo.MainActivity$1.run(MainActivity.java:33)

W/System.err: Caused by: android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname)

W/System.err:     at libcore.io.Linux.android_getaddrinfo(Native Method)

W/System.err:     at libcore.io.BlockGuardOs.android_getaddrinfo(BlockGuardOs.java:172)

W/System.err:     at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:137)

W/System.err: ... 17 more


# 相关课程内容截图

# 尝试过的解决思路和结果

# 粘贴全部相关代码,切记添加代码注释(请勿截图)

;

;

;
;
;

;
;
;
;
;
;
;

{
    = ;

    (savedInstanceState) {
        .onCreate(savedInstanceState);
        setContentView(..);
    }

    (v){
        (v.getId()){
            ..:
                (){
                    () {
                        .run();
                        get();
                    }
                }.start();

                ;
            ..:
                ;
        }
    }

    () {
        {
            = URL();
            = () .openConnection();
            .setRequestMethod();
            .setConnectTimeout();
            = .getResponseCode();
            (==.){    = .getInputStream();
                [] = [];
                len = ;
                = ByteArrayOutputStream();
                ((len=.read()) > -){
                    .write(,,len);
                }
                = String(.toByteArray());
                .(, +);


            }
        } (e) {
            e.printStackTrace();
        } (e) {
            e.printStackTrace();
        }
    }
}


在这里输入代码,可通过选择【代码语言】突出显示

正在回答

登陆购买课程后可参与讨论,去登陆

1回答

同学进行网纲请求时,地址没有写全吧?你得把协议也写上,例如:https://www.imooc.com

  • Charles_hzr 提问者 #1
    写全了,问题找到了,是虚拟机没有联网,要把电脑联到有线网络才行,WiFi不行,不知道什么原因?
    2020-10-26 18:40:10
  • 好帮手慕雪 回复 提问者 Charles_hzr #2
    嗯嗯,是的,虚拟机的话不能用wifi。
    2020-10-26 18:58:24
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
2.Android 网络操作与流行框架
  • 参与学习           人
  • 提交作业       220    份
  • 解答问题       1800    个

本阶段是联网及数据处理的必备技能。课程从网络基础知识到线程间协同工作、异步下载处理;从文件存储、到轻量级数据库SQLite的使用;最后利用最流程的第三方框架助你快速开发企业级APP。

了解课程
请稍等 ...
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师