有啥办法可以在 Mac 上的 android studio 3.5.1 中修复这个错误

Posted

技术标签:

【中文标题】有啥办法可以在 Mac 上的 android studio 3.5.1 中修复这个错误【英文标题】:Is there any way to fix this error in android studio 3.5.1 on Mac有什么办法可以在 Mac 上的 android studio 3.5.1 中修复这个错误 【发布时间】:2020-03-01 01:45:15 【问题描述】:

我正在尝试从我的 android 应用程序下载网页内容。但是每当我跑步时,我都会遇到以下问题。我在 Mac 上使用的是 android studio 3.5.1。

这里有一些代码..

protected String doInBackground(String... urls) 
            String result = "";
            URL url;
            HttpURLConnection httpURLConnection= null;
            try 
                url = new URL(urls[0]);
                httpURLConnection = (HttpURLConnection) url.openConnection();
                InputStream inputStream = httpURLConnection.getInputStream();
                InputStreamReader reader = new InputStreamReader(inputStream);

                int data = reader.read();

                while (data != -1)
                    char current = (char) data;
                    result += current;
                    data = reader.read();
                
                return result;
             catch (Exception e) 
                e.printStackTrace();
                return "Failed";
            
        

以下是错误代码:

2019-11-04 23:43:52.801 19692-19692/? I/nloadwebconten: Not late-enabling -Xcheck:jni (already on)

2019-11-04 23:43:52.870 19692-19692/? E/nloadwebconten: Unknown bits set in runtime_flags: 0x8000

2019-11-04 23:43:52.872 19692-19692/? W/nloadwebconten: Unexpected CPU variant for X86 using defaults: x86

2019-11-04 23:43:53.355 19692-19721/com.example.downloadwebcontent D/libEGL: Emulator has host GPU support, qemu.gles is set to 1.

2019-11-04 23:43:53.340 19692-19692/com.example.downloadwebcontent W/RenderThread: type=1400 audit(0.0:147): avc: denied  write  for name="property_service" dev="tmpfs" ino=840 scontext=u:r:untrusted_app:s0:c136,c256,c512,c768 tcontext=u:object_r:property_socket:s0 tclass=sock_file permissive=0

2019-11-04 23:43:53.356 19692-19721/com.example.downloadwebcontent W/libc: Unable to set property "qemu.gles" to "1": connection failed; errno=13 (Permission denied)

2019-11-04 23:43:53.386 19692-19721/com.example.downloadwebcontent D/libEGL: loaded /vendor/lib/egl/libEGL_emulation.so

2019-11-04 23:43:53.406 19692-19721/com.example.downloadwebcontent D/libEGL: loaded /vendor/lib/egl/libGLESv1_CM_emulation.so

2019-11-04 23:43:53.464 19692-19721/com.example.downloadwebcontent D/libEGL: loaded /vendor/lib/egl/libGLESv2_emulation.so

2019-11-04 23:43:53.680 19692-19692/com.example.downloadwebcontent W/nloadwebconten: Accessing hidden method Landroid/view/View;computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)

2019-11-04 23:43:53.686 19692-19692/com.example.downloadwebcontent W/nloadwebconten: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)

2019-11-04 23:43:53.815 19692-19727/com.example.downloadwebcontent D/NetworkSecurityConfig: No Network Security Config specified, using platform default

2019-11-04 23:43:53.855 19692-19727/com.example.downloadwebcontent W/System.err: java.net.SocketException: socket failed: EPERM (Operation not permitted)

2019-11-04 23:43:53.856 19692-19727/com.example.downloadwebcontent W/System.err:     at java.net.Socket.createImpl(Socket.java:492)

2019-11-04 23:43:53.856 19692-19727/com.example.downloadwebcontent W/System.err:     at java.net.Socket.getImpl(Socket.java:552)

2019-11-04 23:43:53.856 19692-19727/com.example.downloadwebcontent W/System.err:     at java.net.Socket.setSoTimeout(Socket.java:1180)

2019-11-04 23:43:53.865 19692-19727/com.example.downloadwebcontent W/System.err:     at com.android.okhttp.internal.io.RealConnection.connectSocket(RealConnection.java:143)

2019-11-04 23:43:53.865 19692-19727/com.example.downloadwebcontent W/System.err:     at com.android.okhttp.internal.io.RealConnection.connect(RealConnection.java:116)

2019-11-04 23:43:53.865 19692-19727/com.example.downloadwebcontent W/System.err:     at com.android.okhttp.internal.http.StreamAllocation.findConnection(StreamAllocation.java:186)

2019-11-04 23:43:53.866 19692-19727/com.example.downloadwebcontent W/System.err:     at com.android.okhttp.internal.http.StreamAllocation.findHealthyConnection(StreamAllocation.java:128)

2019-11-04 23:43:53.866 19692-19727/com.example.downloadwebcontent W/System.err:     at com.android.okhttp.internal.http.StreamAllocation.newStream(StreamAllocation.java:97)

2019-11-04 23:43:53.866 19692-19727/com.example.downloadwebcontent W/System.err:     at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:289)

2019-11-04 23:43:53.866 19692-19727/com.example.downloadwebcontent W/System.err:     at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:232)

2019-11-04 23:43:53.866 19692-19727/com.example.downloadwebcontent W/System.err:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:465)

2019-11-04 23:43:53.866 19692-19727/com.example.downloadwebcontent W/System.err:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:411)

2019-11-04 23:43:53.866 19692-19727/com.example.downloadwebcontent W/System.err:     at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:248)

2019-11-04 23:43:53.866 19692-19727/com.example.downloadwebcontent W/System.err:     at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:211)

2019-11-04 23:43:53.866 19692-19727/com.example.downloadwebcontent W/System.err:     at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:30)

2019-11-04 23:43:53.867 19692-19727/com.example.downloadwebcontent W/System.err:     at com.example.downloadwebcontent.MainActivity$DownloadTask.doInBackground(MainActivity.java:28)

2019-11-04 23:43:53.867 19692-19727/com.example.downloadwebcontent W/System.err:     at com.example.downloadwebcontent.MainActivity$DownloadTask.doInBackground(MainActivity.java:18)

2019-11-04 23:43:53.867 19692-19727/com.example.downloadwebcontent W/System.err:     at android.os.AsyncTask$3.call(AsyncTask.java:378)

2019-11-04 23:43:53.867 19692-19727/com.example.downloadwebcontent W/System.err:     at java.util.concurrent.FutureTask.run(FutureTask.java:266)

2019-11-04 23:43:53.871 19692-19727/com.example.downloadwebcontent W/System.err:     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:289)

2019-11-04 23:43:53.871 19692-19727/com.example.downloadwebcontent W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)

2019-11-04 23:43:53.871 19692-19727/com.example.downloadwebcontent W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)

2019-11-04 23:43:53.874 19692-19727/com.example.downloadwebcontent W/System.err:     at java.lang.Thread.run(Thread.java:919)

2019-11-04 23:43:53.874 19692-19692/com.example.downloadwebcontent I/info: Failed

2019-11-04 23:43:54.118 19692-19717/com.example.downloadwebcontent D/HostConnection: HostConnection::get() New Host Connection established 0xd4b81f00, tid 19717

2019-11-04 23:43:54.122 19692-19717/com.example.downloadwebcontent D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_3_0 

2019-11-04 23:43:54.145 19692-19717/com.example.downloadwebcontent W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...

2019-11-04 23:43:54.151 19692-19717/com.example.downloadwebcontent D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 0 0

2019-11-04 23:43:54.151 19692-19717/com.example.downloadwebcontent D/EGL_emulation: eglCreateContext: 0xe0204ec0: maj 3 min 0 rcv 3

2019-11-04 23:43:54.153 19692-19717/com.example.downloadwebcontent D/EGL_emulation: eglMakeCurrent: 0xe0204ec0: ver 3 0 (tinfo 0xe0234b90)

2019-11-04 23:43:54.200 19692-19717/com.example.downloadwebcontent W/Gralloc3: mapper 3.x is not supported

2019-11-04 23:43:54.204 19692-19717/com.example.downloadwebcontent D/HostConnection: createUnique: call

2019-11-04 23:43:54.205 19692-19717/com.example.downloadwebcontent D/HostConnection: HostConnection::get() New Host Connection established 0xd4b83760, tid 19717

2019-11-04 23:43:54.206 19692-19717/com.example.downloadwebcontent D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_3_0 

2019-11-04 23:43:54.206 19692-19717/com.example.downloadwebcontent D/eglCodecCommon: allocate: Ask for block of size 0x1000
2019-11-04 23:43:54.207 19692-19717/com.example.downloadwebcontent D/eglCodecCommon: allocate: ioctl allocate returned offset 0x3ff803000 size 0x2000

2019-11-04 23:43:54.234 19692-19717/com.example.downloadwebcontent D/EGL_emulation: eglMakeCurrent: 0xe0204ec0: ver 3 0 (tinfo 0xe0234b90)

2019-11-04 23:43:54.243 19692-19717/com.example.downloadwebcontent D/eglCodecCommon: setVertexArrayObject: set vao to 0 (0) 1 0

【问题讨论】:

你能分享整个堆栈跟踪吗?很难看出哪里出了问题。并且请保持相同的行尾,因为很难理解实际问题是什么。但似乎这是权限问题 - Permission denied 是的,我认为这是主要原因 2019-11-04 23:43:53.356 19692-19721/com.example.downloadwebcontent W/libc:无法将属性“qemu.gles”设置为“ 1":连接失败; errno=13(权限被拒绝) 我谷歌了一下,发现了以下***.com/questions/56266801/…。一个人遇到的问题之一是缺少网络许可。对于一些从模拟器中卸载应用程序就足够了。 基本上我发现了两个失败的原因。一种可能是缺少网络权限,也可能与 SDK 安装有关。 【参考方案1】:

在AndroidManifest.xml的应用标签中添加如下标签

android:usesCleartextTraffic="true"

【讨论】:

我在我的 AndroidManifest.xml 中添加了该标签,它也给了我同样的错误。 那么请您发布您的清单并说明您的基本 url 协议是 http 还是 https【参考方案2】:

我认为这是 android studio 的错误。 今天我刚刚将android studio版本从3.5.1更新到3.5.2,问题就消失了。

【讨论】:

以上是关于有啥办法可以在 Mac 上的 android studio 3.5.1 中修复这个错误的主要内容,如果未能解决你的问题,请参考以下文章

有啥办法能加快Android Studio中Gradle build速度

Android Studio 中的“要求 Wifi 权限限制了仅支持以太网的电视上的应用程序可用性”警告 - 对此有啥办法吗?

用NTFS For Mac对Mac有啥好处

有啥办法可以避免过多的 ActiveRecord 调用?

有啥办法可以让按钮上的图像自动调整大小以适应屏幕?

有啥办法可以访问所有的android通知吗?