android - 在Mac的Android Studio 3.5.1中,有没有办法修复此错误

我正在尝试从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 : 加载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

时间:

将以下标记添加到AndroidManifest.xml的应用程序标记中


android:usesCleartextTraffic="true"



...