ZZR老师写的http请求、插件无法铭文传输即http协议无法使用 原创

BLUESKYHOST
发布于 2021-3-8 16:21
浏览
1收藏

按照ZZR老师的文档配置会走 onFailure 回调 提示无法明文传输

然后我翻阅配置文档的配置开启明文传输有提示

errorMessage:Failed to parse XML configuration from network_security_config

{
  "app": {
    "bundleName": "com.example.shangjinlieren",
    "vendor": "example",
    "version": {
      "code": 1,
      "name": "1.0"
    },
    "apiVersion": {
      "compatible": 4,
      "target": 4,
      "releaseType": "Beta2"
    }
  },
  "deviceConfig": {
    "default": {
      "network": {
        "usesCleartext": true,
        "securityConfig": {
          "domainSettings": {
            "cleartextPermitted": true

          }
        }
      }
    }
  },
  "module": {
    "reqPermissions": [{"name":"ohos.permission.INTERNET"}],
    "package": "com.example.shangjinlieren",
    "name": ".MyApplication",
    "deviceType": [
      "phone"
    ],
    "distro": {
      "deliveryWithInstall": true,
      "moduleName": "entry",
      "moduleType": "entry"
    },
    "abilities": [
      {
        "skills": [
          {
            "entities": [
              "entity.system.home"
            ],
            "actions": [
              "action.system.home",
              "action.list.detail"
            ]
          }
        ],
        "orientation": "unspecified",
        "name": "com.example.shangjinlieren.MainAbility",
        "icon": "$media:icon",
        "description": "$string:mainability_description",
        "label": "shangjinlieren",
        "type": "page",
        "launchType": "standard",
        "metaData": {
          "customizeData": [
            {
              "name": "hwc-theme",
              "value": "androidhwext:style/Theme.Emui.Light.NoTitleBar",
              "extra": ""
            }
          ]
        }
      }
    ]
  }
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.

©著作权归作者所有,如需转载,请注明出处,否则将追究法律责任
标签
收藏 1
回复
举报
5
1
5条回复
按时间正序
/
按时间倒序
白鹿白鹿
白鹿白鹿

确切点说,是安卓高版本和鸿蒙都不支持http这种简单粗暴的传输,要做下其他调整,明天按安卓的方式试试先,不行再来请教大神们

 

回复
2021-3-9 23:08:29
BLUESKYHOST
BLUESKYHOST 回复了 白鹿白鹿
确切点说,是安卓高版本和鸿蒙都不支持http这种简单粗暴的传输,要做下其他调整,明天按安卓的方式试试先,不行再来请教大神们

我对安卓一无所知

回复
2021-3-10 10:23:19
白鹿白鹿
白鹿白鹿

"deviceConfig": {
  "default": {
      "network": {
          "usesCleartext":true
    }
  }
},

把里面的 "cleartextPermitted": true换成 "usesCleartext":true就可以了,sdk和文档不统一,别人不看文档只看sdk,就会犯错,sdk的enum文档是这个字符cleartextPermitted,文档里是 "usesCleartext":true。加油吧

回复
2021-3-10 12:01:40
BLUESKYHOST
BLUESKYHOST 回复了 白鹿白鹿
确切点说,是安卓高版本和鸿蒙都不支持http这种简单粗暴的传输,要做下其他调整,明天按安卓的方式试试先,不行再来请教大神们

我已经解决了

回复
2021-3-10 13:04:45
BLUESKYHOST
BLUESKYHOST

问题是鸿蒙不支持访问本地域名,只支持公网

回复
2021-3-10 13:05:31


回复
    相关推荐