発生している問題・エラーメッセージ
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/ツールのバージョンなど)
参考記事: