报错日志为:

NetworkSecurityConfig: No Network Security Config specified, using platform default

原因是:

网址填写有误,代码如下:

URL url = new URL("http://www.baidu.com");connection = (HttpURLConnection) url.openConnection();connection.setRequestMethod("GET");connection.setConnectTimeout(8000);connection.setReadTimeout(8000);

当我们输入的URL为:

http://www.baidu.com

时,是会报错的,因为虽然我们在浏览器中使用此URL时可以正常访问网站,但是其实实际使用的https协议而不是http协议,可能一般我们也不太注意这个问题,所以才导致这个错误的出现,在android开发中一定要注意填写URL的具体内容才能正确访问网站!

写改为:

https://www.baidu.com

就可以正确访问啦~

关于Android Studio HttpURLconnection使用时报错相关推荐

  1. Android Studio 导入应用时报错 Error:java.lang.RuntimeException: Some file crunching failed, see logs for de

    在app文件夹的build.gradle里加上 复制代码 android { -- aaptOptions.cruncherEnabled = false aaptOptions.useNewCrun ...

  2. android studio 生成APK时报错 libs文件夹拒绝访问

    网上有各种解决办法 但是有一个原因一直没看到有人提起 本人被困惑了很久,特意标记出来: 有一个可能就是在你的build.gradle(Moudle)里面有这么一行 api files('libs/') ...

  3. Android studio安装app时报错 Error: Activity class {} does not exist

    最近经常遇到一些稀奇古怪的问题,比如说启动的时候编译一直是可以的,在install的时候一直失败,报错就是没找到app的入口Activity,经过反复研究发现,应该是卸载不彻底或者某次安装过程突然中断 ...

  4. Android Studio安装应用时报错 installation failed with message Failed to finalize session......

    解决方法: 在AndroidManifest.xml中的provider中的authorities后加几个数字即可. 2017.09.01: 我发现有的项目AndroidManifest.xml中没有 ...

  5. Android Studio 安装虚拟机报错 Intel® HAXM installation failed.

    Android Studio 安装虚拟机时报错 Intel® HAXM installation failed. To install Intel® HAXM follow the instructi ...

  6. 【错误记录】Android Studio 配置 AspectJ 报错 ( all buildscript {} blocks must appear before any plugins {} )

    文章目录 一.报错信息 二.解决方案 一.报错信息 在 Android Studio 配置 AspectJ 报错 : Build file 'D:\002_Project\002_Android_Le ...

  7. android studio 自动引用,Android Studio三方引用报错但是项目可以运行的解决方案

    Android Studio第一次启动的Fetching android sdk component information的问题 1)进入刚安装的Android Studio目录下的bin目录.找到 ...

  8. android studio 编译遇到报错 app:compileDebugJavaWithJavac 处理办法

    android studio编译遇到报错app:compileDebugJavaWithJavac处理办法 android studio 在编译时经常会遇到如下图片中这个错误,但是程序运行时可以正常运 ...

  9. Android studio打包签名报错:Error:(3) Error: app_name is not translated in am (Amharic);

    在使用Android studio签名打包apk时报错: *Error:(3) Error: "app_name" is not translated in "am&qu ...

最新文章

  1. ubuntu 12.04.1升级至ubuntu 12.10出现gcc-4.7依赖库错误的解决办法
  2. 大数据如何学习 cda认证_第十届CDA认证考试 LEVEL 1 优秀考生访问录:我是如何备考的?...
  3. node-mongo封装
  4. 如何破解无线路由器密码,如何破解WEP密码,破解无线路由器
  5. python初步入门_python如何入门
  6. java操作word (jacob)
  7. hadoop 2.7 java_Hadoop2.7环境搭建---Java环境变量
  8. wpf 代码获取contextmenu_[C#] 转:在WPF里面获取右键弹出菜单(ContextMenu)的鼠标点击源(Owner)控件...
  9. 分布式一致性算法2PC和3PC
  10. AOJ 1312 Where's Wally 题解《挑战程序设计竞赛》
  11. 输错密码?这个 sudo 会“嘲讽”你
  12. 光山二高2021高考成绩查询,光山县第二高级中学2019高考成绩和历年成绩汇总
  13. Excel宏去除汉字
  14. 音乐文件加密歌曲转换器mp3
  15. linux下如何实现pgadmin备份,linux下pgAdmin4安装
  16. 密码学专题 对称加密算法
  17. 微信突然限制,你的小程序链接还好吗?
  18. 逻辑回归算法原理及用于解决多分类问题
  19. 《国富论》阅读笔记05
  20. 动森服务器维护什么时候好,仙境传说RO爱如初见7月1日服务器停机维护

热门文章

  1. 实践是检验真理的唯一标准——《精益创业实战》让你的成功飞起来
  2. Learning a Deep Single Image Contrast Enhancer from Multi-Exposure Images阅读札记
  3. 实验四 数据查询——简单查询 Sql Server数据库实验
  4. html button去除默认样式
  5. 【Redis】Info Stats - 监控使用情况
  6. 对勾函数的性质及其应用
  7. 【2017年计算机408统考真题】计组13题 主存储器
  8. IOS 设置icon 出现的bug The app icon set named “AppIcon“ did not have any applicable content.
  9. 绕过黑名单检查实现文件上传1 ——合天网安实验室学习笔记
  10. 中小企业融资解决方案