0
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.

【Flutter・Android】ブラウザを開く際「ERR_CLEARTEXT_NOT_ PERMITTED」が出たときの対処法

Posted at

問題

FlutterやKotlinでAndroidアプリを開発した際、ブラウザを開こうとすると以下のような「ERR_CLEARTEXT_NOT_ PERMITTED」というエラーが出ることがある。

clear.gif

対処法

AndroidManifest.xmlにandroid:usesCleartextTraffic="true"を設定する。

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.sample.url">
   <uses-permission android:name="android.permission.INTERNET"/>
   <application
        android:label="url"

        android:usesCleartextTraffic="true" ←これ

        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"

すると以下のように、ブラウザを開くことができる。

http.gif

補足

このエラーはHTTP通信(URLがhttpsではなくhttpから始まる)ときに起こる。

なので、httpsから始まるURLなら上のような修正をしなくてもブラウザを開くことができる。
https.gif

0
0
0

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
0
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?