質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.49%
Flutter

Flutterは、iOSとAndroidのアプリを同じコードで開発するためのフレームワークです。オープンソースで開発言語はDart。双方のプラットフォームにおける高度な実行パフォーマンスと開発効率を提供することを目的としています。

Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

Q&A

1回答

1878閲覧

【Flutter】HTTP通信の許可

Tetsukick

総合スコア297

Flutter

Flutterは、iOSとAndroidのアプリを同じコードで開発するためのフレームワークです。オープンソースで開発言語はDart。双方のプラットフォームにおける高度な実行パフォーマンスと開発効率を提供することを目的としています。

Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

0グッド

0クリップ

投稿2021/02/18 09:56

発生している問題・エラーメッセージ

HTTP通信を許可させたい。
が、IPアドレスのドメインを許可させようとすると、以下のようなエラーが発生する。

Dart Unhandled Exception: Invalid argument (domain): Invalid domain name: "34.101.XXX.XXX"

該当のソースコード

android/app/src/main/res/xml/network_security_config.xml

dart

1<?xml version="1.0" encoding="utf-8"?> 2<network-security-config> 3 <domain-config cleartextTrafficPermitted="true"> 4 <domain includeSubdomains="true">34.101.XXX.XXX</domain> 5 </domain-config> 6</network-security-config> 7

android/app/src/main/AndroidManifest.xml

dart

1<manifest xmlns:android="http://schemas.android.com/apk/res/android" 2 package="XXX"> 3 <!-- io.flutter.app.FlutterApplication is an android.app.Application that 4 calls FlutterMain.startInitialization(this); in its onCreate method. 5 In most cases you can leave this as-is, but you if you want to provide 6 additional functionality it is fine to subclass or reimplement 7 FlutterApplication and put your custom class here. --> 8 <uses-permission android:name="android.permission.INTERNET" /> 9 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 10 <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" /> 11 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 12 13 <application 14 android:name=".Application" 15 android:icon="@mipmap/launcher_icon" 16 android:usesCleartextTraffic="true" 17 android:label="@string/app_name"> 18 19 <meta-data android:name="io.flutter.network-policy" 20 android:resource="@xml/network_security_config"/> 21 <meta-data 22 android:name="com.google.android.geo.API_KEY" 23 android:value="${GEO_API_KEY}"/> 24 <activity 25 android:name=".MainActivity" 26 android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" 27 android:hardwareAccelerated="true" 28 android:launchMode="singleTop" 29 android:theme="@style/LaunchTheme" 30 android:windowSoftInputMode="adjustResize"> 31 <!-- Specifies an Android theme to apply to this Activity as soon as 32 the Android process has started. This theme is visible to the user 33 while the Flutter UI initializes. After that, this theme continues 34 to determine the Window background behind the Flutter UI. --> 35 36 <meta-data 37 android:name="io.flutter.embedding.android.NormalTheme" 38 android:resource="@style/NormalTheme" /> 39 40 <!-- Displays an Android View that continues showing the launch screen 41 Drawable until Flutter paints its first frame, then this splash 42 screen fades out. A splash screen is useful to avoid any visual 43 gap between the end of Android's launch screen and the painting of 44 Flutter's first frame. --> 45 <meta-data 46 android:name="io.flutter.embedding.android.SplashScreenDrawable" 47 android:resource="@drawable/launch_background" /> 48 <meta-data 49 android:name="com.google.firebase.messaging.default_notification_channel_id" 50 android:value="@string/default_notification_channel_id" /> 51 52 <intent-filter> 53 <action android:name="android.intent.action.MAIN" /> 54 <category android:name="android.intent.category.LAUNCHER" /> 55 </intent-filter> 56 <intent-filter> 57 <action android:name="FLUTTER_NOTIFICATION_CLICK" /> 58 <category android:name="android.intent.category.DEFAULT" /> 59 </intent-filter> 60 </activity> 61 <!-- Don't delete the meta-data below. 62 This is used by the Flutter tool to generate GeneratedPluginRegistrant.java --> 63 <meta-data 64 android:name="flutterEmbedding" 65 android:value="2" /> 66 </application> 67</manifest>

試したこと

android/app/src/main/res/xml/network_security_config.xmlで指定するドメインを文字列に変更するとビルドは通る。

補足情報(FW/ツールのバージョンなど)

参考記事:

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

hiroshihorie

2021/02/20 13:45

ドメイン文字列にすると何も問題ないのでしょうか。
guest

回答1

0

DartではIPアドレス指定ができないと言う未解決なisuueがありました。参考にしてみてください。
該当のissue

投稿2021/02/21 02:46

kureta

総合スコア18

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.49%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問