1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Solar2DのAndroidアプリにusesCleartextTrafficを設定する

Last updated at Posted at 2022-03-09

http通信エラー

Solar2Dで開発したAndroidアプリからサーバーへhttp通信しようとすると、usesCleartextTrafficがデフォルトfalseのためエラーが発生しました。

解決方法

最も良いのはhttps通信にすることですが、諸事情によりそれはできないので、プロジェクト直下にAndroidResources/res/xml/network_security_config.xmlを作成して解決しました。

network_security_config.xml
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">sample.com</domain>
    </domain-config>
</network-security-config>

補足

usesCleartextTrafficをtrueにするため、build.settingsのapplicationChildElementsにandroid:usesCleartextTraffic="true"を追加しようと試みましたがうまくAndroidManifest.xmlには記述できず、この解決方法で対応しました。

1
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?